Merge commit '770abf960dab3a2d3a69f4a7745145081c6303b1'

This commit is contained in:
Trung Dong Huynh 2016-11-28 11:02:48 +00:00
commit a47710c716

View File

@ -11,7 +11,7 @@ events {
http { http {
include /etc/nginx/mime.types; include /etc/nginx/mime.types;
default_type application/octet-stream; default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' log_format main '$remote_addr - $remote_user [$time_local] "$request" '
@ -32,57 +32,57 @@ http {
upstream app { upstream app {
server django:5000; server django:5000;
} }
server { server {
listen 80; listen 80;
server_name ___my.example.com___ www.___my.example.com___; server_name ___my.example.com___ www.___my.example.com___;
location /.well-known/acme-challenge { location /.well-known/acme-challenge {
# Since the certbot container isn't up constantly, need to resolve ip dynamically using docker's dns # Since the certbot container isn't up constantly, need to resolve ip dynamically using docker's dns
resolver ___NAMESERVER___; resolver ___NAMESERVER___;
set $certbot_addr_port certbot:80; set $certbot_addr_port certbot:80;
proxy_pass http://$certbot_addr_port; proxy_pass http://$certbot_addr_port;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
} }
location / { location / {
return 301 https://$server_name$request_uri; return 301 https://$server_name$request_uri;
} }
} }
server { server {
listen 443; listen 443;
server_name ___my.example.com___ www.___my.example.com___; server_name ___my.example.com___ www.___my.example.com___;
ssl on; ssl on;
ssl_certificate /etc/letsencrypt/live/___my.example.com___/fullchain.pem; ssl_certificate /etc/letsencrypt/live/___my.example.com___/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/___my.example.com___/privkey.pem; ssl_certificate_key /etc/letsencrypt/live/___my.example.com___/privkey.pem;
ssl_session_timeout 5m; ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_prefer_server_ciphers on; ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m; ssl_session_cache shared:SSL:10m;
ssl_dhparam /etc/ssl/private/dhparams.pem; ssl_dhparam /etc/ssl/private/dhparams.pem;
location /.well-known/acme-challenge { location /.well-known/acme-challenge {
resolver ___NAMESERVER___; resolver ___NAMESERVER___;
set $certbot_addr_port certbot:443; set $certbot_addr_port certbot:443;
proxy_pass http://$certbot_addr_port; proxy_pass http://$certbot_addr_port;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Proto https;
} }
location / { location / {
# checks for static file, if not found proxy to app # checks for static file, if not found proxy to app
try_files $uri @proxy_to_app; try_files $uri @proxy_to_app;
} }
# cookiecutter-django app # cookiecutter-django app
location @proxy_to_app { location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host; proxy_set_header Host $http_host;
proxy_redirect off; proxy_redirect off;
@ -91,6 +91,6 @@ http {
} }
} }
} }