Created
November 19, 2013 22:39
-
-
Save garlandkr/7553856 to your computer and use it in GitHub Desktop.
attempt to proxy multiple servers in nginx
This file contains hidden or 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 mysite { | |
| server unix:/tmp/gunicorn.sock fail_timeout=0; | |
| } | |
| upstream php5-fpm { | |
| server unix:/var/run/php5-fpm.sock; | |
| } | |
| server { | |
| listen 80; | |
| server_name mysite.com; | |
| client_max_body_size 4G; | |
| index index.php; | |
| access_log /var/log/nginx/mainsite.access.log; | |
| error_log /var/log/nginx/mainsite.error.log; | |
| error_page 404 = @notfound; | |
| location @notfound { | |
| rewrite .* / permanent; | |
| } | |
| location /static/ { | |
| alias /opt/mysite/static/; | |
| } | |
| location /blog { | |
| proxy_pass http://php5-fpm; | |
| } | |
| location / { | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header Host $http_host; | |
| proxy_redirect off; | |
| proxy_pass http://mysite; | |
| } | |
| location = /favicon.ico { | |
| log_not_found off; | |
| access_log off; | |
| } | |
| location = /robots.txt { | |
| allow all; | |
| log_not_found off; | |
| access_log off; | |
| } | |
| location ~ /\. { | |
| deny all; | |
| } | |
| location ~* /(?:uploads|files)/.*\.php$ { | |
| deny all; | |
| } | |
| location ~ .php$ { | |
| try_files $uri =404; | |
| include /etc/nginx/fastcgi_params; | |
| fastcgi_index index.php; | |
| fastcgi_pass php5-fpm; | |
| fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment