Skip to content

Instantly share code, notes, and snippets.

@eric-wu
Last active October 27, 2022 01:45
Show Gist options
  • Save eric-wu/8483112 to your computer and use it in GitHub Desktop.
Save eric-wu/8483112 to your computer and use it in GitHub Desktop.
Nginx reverse proxy set up behind a elastic load balancer and in front of a Play web app. Redirects http to https.
# 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;
}
}
@ferarnoled
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment