Skip to content

Instantly share code, notes, and snippets.

@yrgoldteeth
Forked from davidcelis/nginx.conf
Created December 30, 2015 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yrgoldteeth/6582210baa9f8eb6f19d to your computer and use it in GitHub Desktop.
Save yrgoldteeth/6582210baa9f8eb6f19d to your computer and use it in GitHub Desktop.
Nginx configuration to redirect HTTP traffic to HTTPS (Puma)
upstream puma {
server unix:///var/www/app/shared/tmp/sockets/puma.sock fail_timeout=0;
}
server {
listen 80 default deferred;
server_name example.com;
rewrite ^/(.+) https://example.com/$1 permanent;
}
server {
listen 443 ssl spdy;
server_name example.com;
ssl_certificate /etc/ssl/example.com-unified.crt;
ssl_certificate_key /etc/ssl/example.com.key;
root /var/www/example.com/current/public;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
if (-f $request_filename) {
break;
}
proxy_pass http://puma;
}
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