Last active
June 25, 2019 18:19
-
-
Save dnprock/53fa74153d29557aa699 to your computer and use it in GitHub Desktop.
meteor nginx load balance with sticky session, used by vida.io
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
# Sticky session module for nginx | |
# https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/ | |
# nginx configure command: ./configure --with-http_ssl_module --add-module=../nginx-sticky-module-ng/ --sbin-path=/usr/local/sbin --with-http_gzip_static_module | |
upstream vida_node_server { | |
sticky path=/; | |
server 127.0.0.1:3000 max_fails=3 fail_timeout=30s; | |
server [server2]:3000 max_fails=3 fail_timeout=30s; | |
} | |
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
server { | |
listen 80; | |
server_name vida.io; | |
location ^~ /(assets)/ { | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
} | |
location / { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://vida_node_server; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
proxy_max_temp_file_size 0; | |
} | |
error_page 500 502 503 504 /500; | |
client_max_body_size 4G; | |
} | |
server { | |
listen 443; | |
server_name vida.io; | |
ssl on; | |
ssl_certificate [path_to_cert]; | |
ssl_certificate_key [path_to_cert_key]; | |
ssl_session_timeout 5m; | |
ssl_protocols SSLv2 SSLv3 TLSv1; | |
ssl_ciphers HIGH:!aNULL:!MD5; | |
ssl_prefer_server_ciphers on; | |
location ^~ /(assets)/ { | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
} | |
try_files $uri/index.html $uri; | |
location / { | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto https; | |
proxy_redirect off; | |
proxy_pass http://vida_node_server; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
proxy_max_temp_file_size 0; | |
} | |
error_page 500 502 503 504 /500; | |
client_max_body_size 4G; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment