@@ -16,7 +16,6 @@ COPY conf.d/nginx.conf /etc/nginx/nginx.conf | |||||
COPY conf.d/mime.types /etc/nginx/mime.types | COPY conf.d/mime.types /etc/nginx/mime.types | ||||
RUN rm /etc/nginx/conf.d/default.conf | RUN rm /etc/nginx/conf.d/default.conf | ||||
COPY conf.d/default.conf /etc/nginx/conf.d/default.conf | |||||
RUN mkdir /dockersible | RUN mkdir /dockersible | ||||
COPY dockersible/ /dockersible | COPY dockersible/ /dockersible | ||||
@@ -1,5 +1,6 @@ | |||||
server { | server { | ||||
listen 80; | |||||
listen 80 default_server; | |||||
listen [::]:80 default_server; | |||||
{% if domain %} | {% if domain %} | ||||
server_name {{ domain }} www.{{ domain }}; | server_name {{ domain }} www.{{ domain }}; | ||||
{% else %} | {% else %} | ||||
@@ -54,6 +55,7 @@ server { | |||||
proxy_set_header Host $host; | proxy_set_header Host $host; | ||||
proxy_set_header X-Forwarded-Proto $scheme; | proxy_set_header X-Forwarded-Proto $scheme; | ||||
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 X-Url-Scheme $scheme; | |||||
proxy_redirect off; | proxy_redirect off; | ||||
} | } | ||||
@@ -63,6 +65,7 @@ server { | |||||
proxy_set_header Host $host; | proxy_set_header Host $host; | ||||
proxy_set_header X-Forwarded-Proto $scheme; | proxy_set_header X-Forwarded-Proto $scheme; | ||||
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 X-Url-Scheme $scheme; | |||||
proxy_redirect off; | proxy_redirect off; | ||||
} | } | ||||
} | } |
@@ -1,4 +0,0 @@ | |||||
server { | |||||
listen 80 default_server; | |||||
return 444; | |||||
} |
@@ -6,7 +6,7 @@ from dockersible.files import copy, template | |||||
def get_ssl_context(environ): | def get_ssl_context(environ): | ||||
domain = environ['domain'] | |||||
domain = environ['DOMAIN'] | |||||
nginx_info = { | nginx_info = { | ||||
'domain': domain, | 'domain': domain, | ||||
'dhparam': False, | 'dhparam': False, | ||||
@@ -44,8 +44,8 @@ def get_certificates(domain): | |||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
pk, crt = get_certificates(os.environ['domain']) | |||||
pk, crt = get_certificates(os.environ['DOMAIN']) | |||||
copy(source=pk, destination='/etc/ssl/private', basename='private.key', mode='0600') | copy(source=pk, destination='/etc/ssl/private', basename='private.key', mode='0600') | ||||
copy(source=crt, destination='/etc/ssl/certs', basename='certificate.crt', mode='0644') | copy(source=crt, destination='/etc/ssl/certs', basename='certificate.crt', mode='0644') | ||||
template('/backend.conf.j2', get_ssl_context(os.environ), '/etc/nginx/conf.d/backend.conf') | |||||
template('/backend.conf.j2', get_ssl_context(os.environ), '/etc/nginx/conf.d/default.conf') |