Skip to content

Instantly share code, notes, and snippets.

@hungmi
Last active October 12, 2018 08:19
Show Gist options
  • Save hungmi/362258698eeada3788f9c2bcf10be6ea to your computer and use it in GitHub Desktop.
Save hungmi/362258698eeada3788f9c2bcf10be6ea to your computer and use it in GitHub Desktop.
/etc/nginx/sites-available/DomainName
# config/nginx.conf
upstream puma {
server unix:///home/deploy/apps/AppName/shared/tmp/sockets/puma.sock;
}
server {
server_name example.com www.example.com.tw;
root /home/deploy/apps/AppName/current/public;
access_log /home/deploy/apps/AppName/current/log/nginx.access.log;
error_log /home/deploy/apps/AppName/current/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Forwarded-Ssl on;
proxy_pass http://puma;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
add_header X-Frame-Options "DENY";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; always";
}
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server deferred;
server_name example.com www.example.com.tw;
return 404; # managed by Certbot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment