Last active
June 15, 2018 13:11
-
-
Save davidcelis/69eb6c707b6f4a6c1391 to your computer and use it in GitHub Desktop.
Nginx configuration to redirect HTTP traffic to HTTPS (Puma)
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 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; | |
} |
i made a mistake how do i fix the rewrite
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also cleaner and less prone to mistakes/corner-cases, since handled by nginx directly ootb.