Last active
August 29, 2015 14:14
-
-
Save smereczynski/67720fa04b174400cab2 to your computer and use it in GitHub Desktop.
NGINX rev proxy on Azure
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
| ## Basic reverse proxy server ## | |
| ## Apache (nginxtest2) backend for example.net.pl ## | |
| upstream apachephp { | |
| server 10.1.0.5:80; #Apache1 | |
| } | |
| ## Apache (nginxtest3) backend for static.example.net.pl ## | |
| upstream apachestatic { | |
| server 10.1.0.6:80; #Apache2 | |
| } | |
| ## Start example.net.pl ## | |
| server { | |
| listen 80; | |
| server_name example.net.pl; | |
| access_log /var/log/nginx/example.access.log; | |
| error_log /var/log/nginx/example.error.log; | |
| root /usr/share/nginx/html; | |
| index index.html index.htm; | |
| ## send request back to apache1 ## | |
| location / { | |
| proxy_pass http://apachephp; | |
| proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; | |
| proxy_redirect off; | |
| proxy_buffering off; | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| } | |
| } | |
| ## End example.com ## | |
| ## START static.example.net.pl ## | |
| server { | |
| listen 80; | |
| server_name static.example.net.pl; | |
| access_log /var/log/nginx/static.example.access.log; | |
| error_log /var/log/nginx/static.example.error.log; | |
| root /usr/local/nginx/html; | |
| index index.html; | |
| location / { | |
| proxy_pass http://apachestatic; | |
| proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; | |
| proxy_redirect off; | |
| proxy_buffering off; | |
| proxy_set_header Host static.example.net.pl; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| } | |
| location ~* ^.+\.(atom|bmp|bz2|doc|docx|eot|exe|gif|gz|ico|jpeg|jpg|mid|midi|mp4|ogg|ogv|otf|pdf|png|ppt|pptx|rar|rss|rtf|svg|svgz|swf|tar|tgz|ttf|txt|wav|woff|xls|zip)$ { | |
| access_log off; | |
| log_not_found off; | |
| expires max; | |
| proxy_pass http://apachestatic; | |
| } | |
| } | |
| ## END static.example.net.pl ## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment