mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-24 10:34:06 +03:00
b766b7c4bc
Added new replacement variable for nginx-secure: ___NAMESERVER___. This is parsed out from the system resolv.conf and used to resolve the ip's of the containers dynamically Modified nginx-secure.conf to resolve certbot dynamically NOTE: if using `docker-compose run certbot ...`, set `--name certbot` so it can be resolved properly Added CMD /start.sh back in, guessing it was removed by accident
97 lines
2.4 KiB
Plaintext
Executable File
97 lines
2.4 KiB
Plaintext
Executable File
user nginx;
|
|
worker_processes 1;
|
|
|
|
error_log /var/log/nginx/error.log warn;
|
|
pid /var/run/nginx.pid;
|
|
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
'$status $body_bytes_sent "$http_referer" '
|
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
access_log /var/log/nginx/access.log main;
|
|
|
|
sendfile on;
|
|
#tcp_nopush on;
|
|
|
|
keepalive_timeout 65;
|
|
|
|
proxy_headers_hash_bucket_size 52;
|
|
|
|
gzip on;
|
|
|
|
upstream app {
|
|
server django:5000;
|
|
}
|
|
server {
|
|
listen 80;
|
|
server_name ___my.example.com___ www.___my.example.com___;
|
|
|
|
location /.well-known/acme-challenge {
|
|
# Since the certbot container isn't up constantly, need to resolve ip dynamically using docker's dns
|
|
resolver ___NAMESERVER___;
|
|
set $certbot_addr_port certbot:80;
|
|
proxy_pass http://$certbot_addr_port;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $remote_addr;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location / {
|
|
return 301 https://$server_name$request_uri;
|
|
}
|
|
|
|
}
|
|
|
|
server {
|
|
listen 443;
|
|
server_name ___my.example.com___ www.___my.example.com___;
|
|
|
|
ssl on;
|
|
ssl_certificate /etc/letsencrypt/live/___my.example.com___/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/___my.example.com___/privkey.pem;
|
|
ssl_session_timeout 5m;
|
|
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
|
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
|
|
ssl_prefer_server_ciphers on;
|
|
|
|
ssl_session_cache shared:SSL:10m;
|
|
ssl_dhparam /etc/ssl/private/dhparams.pem;
|
|
|
|
location /.well-known/acme-challenge {
|
|
resolver ___NAMESERVER___;
|
|
set $certbot_addr_port certbot:443;
|
|
proxy_pass http://$certbot_addr_port;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $remote_addr;
|
|
proxy_set_header X-Forwarded-Proto https;
|
|
}
|
|
|
|
location / {
|
|
# checks for static file, if not found proxy to app
|
|
try_files $uri @proxy_to_app;
|
|
}
|
|
|
|
# cookiecutter-django 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|