Last active
August 29, 2015 14:07
-
-
Save o3bvv/9655362d69f84f4167ca to your computer and use it in GitHub Desktop.
Nginx example
This file contains hidden or 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 localhost; | |
location /api { | |
return 497; # Forbid execution of API calls via plain HTTP | |
} | |
location / { | |
rewrite ^ https://$host:443$request_uri? permanent; | |
} | |
} | |
server { | |
listen 443 ssl; | |
server_name localhost; | |
ssl_certificate security/your_certificate.crt; | |
ssl_certificate_key security/your_certificate_pk.pem; | |
ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2; | |
ssl_ciphers HIGH:!aNULL:!MD5; | |
ssl_prefer_server_ciphers on; | |
location / { | |
uwsgi_pass 127.0.0.1:9001; | |
uwsgi_intercept_errors on; | |
include uwsgi_params; | |
expires off; | |
error_page 404 = @fallback; | |
} | |
location @fallback { | |
proxy_pass http://127.0.0.1:5000; | |
} | |
location /docs { | |
alias /var/virtualenvs/YOUR_PROJECT_NAME/src/YOUR_PROJECT_NAME/docs/_build/html; | |
expires off; | |
} | |
location /favicon.ico { | |
root /var/virtualenvs/YOUR_PROJECT_NAME/var/static; | |
expires off; | |
} | |
location /static { | |
root /var/virtualenvs/YOUR_PROJECT_NAME/var; | |
gzip_comp_level 1; | |
gzip_proxied any; | |
gzip_types text/plain | |
text/css | |
text/xml | |
text/javascript | |
application/x-javascript | |
application/xml | |
application/xml+rss; | |
expires off; | |
} | |
location /uploads { | |
root /var/virtualenvs/YOUR_PROJECT_NAME/var; | |
expires off; | |
} | |
} | |
log_format combined_timed '$remote_addr - $remote_user [$time_local] ' | |
'"$request" $status $body_bytes_sent ' | |
'"$http_referer" "$http_user_agent" ' | |
'$request_time $upstream_response_time $gzip_ratio'; | |
access_log /var/log/nginx/YOUR_PROJECT_NAME-access.log combined_timed; | |
client_max_body_size 250m; | |
uwsgi_read_timeout 300; | |
uwsgi_connect_timeout 300; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment