Skip to content

Instantly share code, notes, and snippets.

@jeroenbourgois
Created February 26, 2011 18:23
Show Gist options
  • Save jeroenbourgois/845463 to your computer and use it in GitHub Desktop.
Save jeroenbourgois/845463 to your computer and use it in GitHub Desktop.
nginx-site-conf
server {
listen 80;
server_name dropbox.local;
root /Users/Jeroen/Dropbox/development/online;
autoindex on;
location / {
index index.html index.php;
# try_files attempts to serve a file or folder, until it reaches the fallback at the end
try_files $uri $uri/ @backend;
}
location @backend {
# essentially the same as passing php requests back to apache
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location ~ \.php {
# this block will catch any requests with a .php extension
# normally in this block data would be passed to a FastCGI process
# these two lines tell Apache the actual IP of the client being forwarded
# Apache requires mod_proxy (http://bit.ly/mod_proxy) for these to work
# Most Apache 2.0+ servers have mod_proxy configured already
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
# this next line adds the Host header so that apache knows which vHost to serve
# the $host variable is automatically set to the hostname Nginx is responding to
proxy_set_header Host $host;
# And now we pass back to apache
# if you're using a side-by-side configuration the IP can be changed to
# apache's bound IP at port 80 such as http://192.170.2.1:80
proxy_pass http://127.0.0.1:8080;
}
# if you don't like seeing all the errors for missing favicon.ico in root
location = /favicon.ico { access_log off; log_not_found off; }
# if you don't like seeing errors for a missing robots.txt in root
location = /robots.txt { access_log off; log_not_found off; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment