Last active
November 15, 2019 18:54
-
-
Save nahanil/b26a44a22660ce36ae1c4dc3d25531b8 to your computer and use it in GitHub Desktop.
nginx thing
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
server { | |
listen 80; | |
server_name myapp.com; | |
location / { | |
# Pass off API and socket requests to the app server | |
proxy_pass http://127.0.0.1:1337; | |
proxy_redirect off; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
} | |
} |
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
# See: https://nginx.org/en/docs/http/load_balancing.html | |
# https://nginx.org/en/docs/http/ngx_http_upstream_module.html | |
upstream my-app { | |
least_conn; | |
server 127.0.0.1:1337; # server 1 | |
server 127.0.0.2:1337; # server 2 | |
server 127.0.0.3:1337; # server 3 | |
} | |
server { | |
listen 80; | |
server_name myapp.com www.myapp.com; | |
location / { | |
# Pass off API and socket requests to the app server | |
proxy_pass http://my-app; | |
proxy_redirect off; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment