Last active
March 8, 2021 20:39
-
-
Save oleoneto/ca55405ec89d36397665c9031115d59a to your computer and use it in GitHub Desktop.
Generic Nginx configuration for serving Django projects over 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
# Configuration assumes use of Let's Encrypt | |
# Site is ONLY served through HTTPS. | |
# Site is served through .example.com and www.example.com | |
# Leo N. | |
server { | |
listen 443 ssl; | |
server_name example.com www.example.com; | |
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; | |
location = /favicon.ico { | |
alias /var/www/example.com/site_static/favicon.ico; | |
} | |
location /static/ { | |
alias /var/www/example.com/site_static/; | |
} | |
location /media/ { | |
alias /var/www/example.com/site_media/; | |
} | |
location / { | |
# Cross-Origin Request... | |
# add_header Access-Control-Allow-Origin *; | |
include uwsgi_params; | |
uwsgi_pass unix:/run/uwsgi/SITE.sock; | |
} | |
} | |
server { | |
listen 80; | |
server_name example.com www.example.com; | |
return 301 https://$host$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment