Created
September 29, 2011 23:37
-
-
Save yosemitebandit/1252240 to your computer and use it in GitHub Desktop.
nginx config file for flask app (behind gunicorn) with ssl
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
server { | |
listen 80; | |
server_name www.yupyupnope.com; | |
rewrite ^/(.*) https://yupyupnope.com/$1 permanent; | |
} | |
server { | |
listen 80; | |
server_name yupyupnope.com; | |
rewrite ^/(.*) https://yupyupnope.com/$1 permanent; | |
} | |
server { | |
listen 443; | |
ssl on; | |
ssl_certificate /etc/ssl/certs/yupyupnope_com.crt; | |
ssl_certificate_key /etc/ssl/private/yupyupnope_com.key; | |
server_name yupyupnope.com; | |
access_log /home/matt/log/yupyupnope.com/access.log; | |
error_log /home/matt/log/yupyupnope.com/error.log; | |
location / { | |
# checks for static files; if not found, proxy to app | |
try_files $uri @proxy_to_app; | |
} | |
location @proxy_to_app { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://app_server; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was very helpful. Just noticed that nginx recommends something besides rewrites when possible: http://wiki.nginx.org/Pitfalls (search for "taxing rewrites").
It would be something like
return 301 https://yupyupnope.com$request_uri;
in your example.