-
-
Save imdjh/c834a3183e4d65742f05cd5a0100dfe1 to your computer and use it in GitHub Desktop.
two port nginx config
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
events { | |
worker_connections 4096; ## Default: 1024 | |
} | |
http { | |
upstream old_rails_puma { | |
server old_app:3000; | |
} | |
upstream new_rails_puma { | |
server new_app:4000; | |
} | |
# Old Rails server config, listen 80 port | |
server { | |
listen 80; | |
root /app/old/public; | |
access_log /var/log/nginx/old_app.access.log; | |
error_log /var/log/nginx/old_app.error.log; | |
try_files $uri/index.html $uri @rails_puma; | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $host; | |
# proxy_set_header X-Forwarded-Proto https; | |
proxy_pass http://old_rails_puma; | |
proxy_redirect off; | |
} | |
# static content | |
location ~ ^/(assets|img|js|javascripts|styles|stylesheets)/ { | |
access_log off; | |
# Per RFC2616 - 1 year maximum expiry | |
expires max; | |
add_header Cache-Control public; | |
# Some browsers still send conditional-GET requests if there's a | |
# Last-Modified header or an ETag header even if they haven't | |
# reached the expiry date sent in the Expires header. | |
add_header Last-Modified ""; | |
add_header ETag ""; | |
break; | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 4G; | |
keepalive_timeout 10; | |
} | |
# New Rails server config, listen 8080 port | |
server { | |
listen 8080; | |
root /app/new/public; | |
access_log /var/log/nginx/new_app.access.log; | |
error_log /var/log/nginx/new_app.error.log; | |
try_files $uri/index.html $uri @rails_puma; | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $host; | |
# proxy_set_header X-Forwarded-Proto https; | |
proxy_pass http://new_rails_puma; | |
proxy_redirect off; | |
} | |
# static content | |
location ~ ^/(assets|img|js|javascripts|styles|stylesheets)/ { | |
access_log off; | |
# Per RFC2616 - 1 year maximum expiry | |
expires 1y; | |
add_header Cache-Control public; | |
# Some browsers still send conditional-GET requests if there's a | |
# Last-Modified header or an ETag header even if they haven't | |
# reached the expiry date sent in the Expires header. | |
add_header Last-Modified ""; | |
add_header ETag ""; | |
break; | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 4G; | |
keepalive_timeout 10; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment