Created
September 12, 2016 20:11
-
-
Save lambda2/9fea3f1f638d0f3bc247ed93a6c1fc02 to your computer and use it in GitHub Desktop.
Config nginx rails for http and https
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
upstream unicorn_blog { | |
server unix:/tmp/unicorn.blog.sock fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name blog.andral.kiwi www.blog.andral.kiwi; | |
root /home/andral/apps/blog/current/public; | |
location ^~ /assets/ { | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
} | |
location ~ ^/(robots.txt|sitemap.xml.gz)/ { | |
root /home/andral/apps/blog/current/public; | |
} | |
try_files $uri/index.html $uri @unicorn_blog; | |
location @unicorn_blog { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://unicorn_blog; | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 20M; | |
keepalive_timeout 10; | |
} |
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
upstream unicorn_little_camp { | |
server unix:/tmp/unicorn.little-camp.sock fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name little.camp www.little.camp; | |
return 301 https://$server_name$request_uri; | |
} | |
server { | |
listen 443 ssl; | |
server_name little.camp www.little.camp; | |
root /home/deployer/apps/little-camp/current/public; | |
ssl_certificate /etc/letsencrypt/live/little.camp/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/little.camp/privkey.pem; | |
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"; | |
location ^~ /assets/ { | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
} | |
location ~ ^/(robots.txt|sitemap.xml.gz)/ { | |
root /home/deployer/apps/little-camp/current/public; | |
} | |
try_files $uri/index.html $uri @unicorn_little_camp; | |
location @unicorn_little_camp { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://unicorn_little_camp; | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 20M; | |
keepalive_timeout 10; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment