From 5827e7fdb29263a5a9d0033657e6d0ab30a9b3b8 Mon Sep 17 00:00:00 2001 From: Dan Mirsky Date: Sun, 19 Jun 2016 00:46:14 -0700 Subject: [PATCH] Changed nginx confs for dockers new networking Docker got rid of legacy links so there are no longer env vars pointing to other containers. Instead, we can reference the containers directly. This fixes problems with let's encrypt related to missing env vars. See notice at the top of https://docs.docker.com/compose/link-env-deprecated/ --- .../compose/nginx/nginx-secure.conf | 4 +-- .../compose/nginx/nginx.conf | 2 +- .../compose/nginx/start.sh | 25 ------------------- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/{{cookiecutter.project_slug}}/compose/nginx/nginx-secure.conf b/{{cookiecutter.project_slug}}/compose/nginx/nginx-secure.conf index 78f90279..c014c282 100755 --- a/{{cookiecutter.project_slug}}/compose/nginx/nginx-secure.conf +++ b/{{cookiecutter.project_slug}}/compose/nginx/nginx-secure.conf @@ -37,7 +37,7 @@ http { server_name ___my.example.com___ www.___my.example.com___; location /.well-known/acme-challenge { - proxy_pass http://___LETSENCRYPT_IP___:___LETSENCRYPT_PORT___; + proxy_pass http://certbot:80; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; @@ -66,7 +66,7 @@ http { ssl_dhparam /etc/ssl/private/dhparams.pem; location /.well-known/acme-challenge { - proxy_pass http://___LETSENCRYPT_HTTPS_IP___:___LETSENCRYPT_HTTPS_PORT___; + proxy_pass http://certbot:443; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; diff --git a/{{cookiecutter.project_slug}}/compose/nginx/nginx.conf b/{{cookiecutter.project_slug}}/compose/nginx/nginx.conf index 91bd96ec..5d7faa39 100644 --- a/{{cookiecutter.project_slug}}/compose/nginx/nginx.conf +++ b/{{cookiecutter.project_slug}}/compose/nginx/nginx.conf @@ -39,7 +39,7 @@ http { server_name ___my.example.com___ ; location /.well-known/acme-challenge { - proxy_pass http://___LETSENCRYPT_IP___:___LETSENCRYPT_PORT___; + proxy_pass http://certbot:80; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; diff --git a/{{cookiecutter.project_slug}}/compose/nginx/start.sh b/{{cookiecutter.project_slug}}/compose/nginx/start.sh index 2079e194..2b358ee7 100755 --- a/{{cookiecutter.project_slug}}/compose/nginx/start.sh +++ b/{{cookiecutter.project_slug}}/compose/nginx/start.sh @@ -5,18 +5,9 @@ echo build starting nginx config echo replacing ___my.example.com___/$MY_DOMAIN_NAME -echo replacing ___LETSENCRYPT_IP___/$LETSENCRYPT_PORT_80_TCP_ADDR -echo replacing ___LETSENCRYPT_PORT___/$LETSENCRYPT_PORT_80_TCP_PORT -echo replacing ___APPLICATION_IP___/$APP_PORT_80_TCP_ADDR -echo replacing ___APPLICATION_PORT___/$APP_PORT_80_TCP_PORT # Put your domain name into the nginx reverse proxy config. sed -i "s/___my.example.com___/$MY_DOMAIN_NAME/g" /etc/nginx/nginx.conf -# Add your app's container IP and port into config -sed -i "s/___APPLICATION_IP___/$APP_PORT_80_TCP_ADDR/g" /etc/nginx/nginx.conf -sed -i "s/___APPLICATION_PORT___/$APP_PORT_80_TCP_PORT/g" /etc/nginx/nginx.conf -sed -i "s/___LETSENCRYPT_IP___/$LETSENCRYPT_PORT_80_TCP_ADDR/g" /etc/nginx/nginx.conf -sed -i "s/___LETSENCRYPT_PORT___/$LETSENCRYPT_PORT_80_TCP_PORT/g" /etc/nginx/nginx.conf cat /etc/nginx/nginx.conf echo . @@ -53,27 +44,11 @@ done sleep 15 echo replacing ___my.example.com___/$MY_DOMAIN_NAME -echo replacing ___LETSENCRYPT_IP___/$LETSENCRYPT_PORT_80_TCP_ADDR -echo replacing ___LETSENCRYPT_PORT___/$LETSENCRYPT_PORT_80_TCP_PORT -echo replacing ___LETSENCRYPT_HTTPS_IP___/$LETSENCRYPT_PORT_443_TCP_ADDR -echo replacing ___LETSENCRYPT_HTTPS_PORT___/$LETSENCRYPT_PORT_443_TCP_PORT -echo replacing ___APPLICATION_IP___/$APP_PORT_80_TCP_ADDR -echo replacing ___APPLICATION_PORT___/$APP_PORT_80_TCP_PORT # Put your domain name into the nginx reverse proxy config. sed -i "s/___my.example.com___/$MY_DOMAIN_NAME/g" /etc/nginx/nginx-secure.conf -# Add LE container IP and port into config -sed -i "s/___LETSENCRYPT_IP___/$LETSENCRYPT_PORT_80_TCP_ADDR/g" /etc/nginx/nginx-secure.conf -sed -i "s/___LETSENCRYPT_PORT___/$LETSENCRYPT_PORT_80_TCP_PORT/g" /etc/nginx/nginx-secure.conf -sed -i "s/___LETSENCRYPT_HTTPS_IP___/$LETSENCRYPT_PORT_443_TCP_ADDR/g" /etc/nginx/nginx-secure.conf -sed -i "s/___LETSENCRYPT_HTTPS_PORT___/$LETSENCRYPT_PORT_443_TCP_PORT/g" /etc/nginx/nginx-secure.conf - -# Add your app's container IP and port into config -sed -i "s/___APPLICATION_IP___/$APP_PORT_80_TCP_ADDR/g" /etc/nginx/nginx-secure.conf -sed -i "s/___APPLICATION_PORT___/$APP_PORT_80_TCP_PORT/g" /etc/nginx/nginx-secure.conf - #go! kill $(ps aux | grep 'nginx' | awk '{print $2}') cp /etc/nginx/nginx-secure.conf /etc/nginx/nginx.conf