Last active
January 12, 2016 09:23
-
-
Save jdcantrell/8028709 to your computer and use it in GitHub Desktop.
Nginx config for having project.dev working locally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream app_server { | |
server localhost:8080 fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name "~^(?<base_dir>.+)\.sim\.bz$"; | |
if ($base_dir = "") { | |
set $base_dir "."; | |
} | |
set $username "jd"; | |
access_log /var/log/nginx/dev.access.log; | |
error_log /var/log/nginx/dev.error.log; | |
location / { | |
root /home/$username/.sites/$base_dir/; | |
index index.html index.htm; | |
try_files $uri/index.html $uri @app; | |
} | |
location /error/ { | |
root /home/$username/.sites/; | |
rewrite ^(/error)(.*)$ /errors$2 break; | |
} | |
location @app { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://app_server; | |
proxy_intercept_errors on; | |
error_page 502 =502 /error/502.html; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment