-
-
Save eric-wu/8483112 to your computer and use it in GitHub Desktop.
| # This sets up a nginx reverse proxy behind a load balancer and in front of | |
| # the Play web app. The setup is illustrated as the following: | |
| # | |
| # LB:80 ==> RP:80 ==> (Redirect to https) | |
| # LB:443 ==> RP:8080 ==> Backend:9001 | |
| # | |
| # LB -- Load Balancer | |
| # RP -- Reverse Proxy | |
| # | |
| # IMPORTANT: Remove the line `include /etc/nginx/sites-enabled/*` from this config | |
| # | |
| http { | |
| ## | |
| # Reverse proxy | |
| ## | |
| proxy_buffering off; | |
| proxy_redirect off; | |
| proxy_http_version 1.1; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Scheme $scheme; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header Host $host; | |
| proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; | |
| upstream dashboard-backend { | |
| server localhost:9001; | |
| } | |
| server { | |
| listen 8080; | |
| server_name dashboard.synapse.org; | |
| location / { | |
| proxy_pass http://dashboard-backend; | |
| } | |
| } | |
| ## | |
| # Redirect http to https | |
| ## | |
| server { | |
| listen 80; | |
| return 301 https://$host$request_uri; | |
| } | |
| } |
Nginx is used to redirect HTTP requests to HTTPS in this example.
In some web servers this is more difficult to achieve so you can use a lightweight server in front to handle that.
Hi Bro,
I want to use your code in my environment ..
Please clarify where should I use elb ip address and my splunk ip/url server address. In you example which is elb name/ip and play web app ?
Also from where we are picking up these parmaters :
proxy_set_header X-Real-IP $remote_addr; -->
proxy_set_header X-Scheme $scheme; -->
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; -->
proxy_set_header Host $host; ->
Regards,
Any idea why you have to set up proxy_buffering off;?
I had to do it on my server config because of some inconsistent issues but have no idea why it worked.
Hi @eric-wu
I am a newbie in this kind of stuff. Could you have me to answer these questions?
Thanks