Skip to content

Commit

Permalink
Fallback to HTTP when no cert is available and letsencrypt is enabled,
Browse files Browse the repository at this point in the history
…fixes #35
  • Loading branch information
kaiyou committed Feb 2, 2017
1 parent 25d8b9e commit a0eeb76
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nginx/Dockerfile
Expand Up @@ -3,3 +3,8 @@ FROM nginx:alpine
RUN apk add --update nginx-lua && rm -rf /var/cache/apk/*

COPY nginx.conf /etc/nginx/nginx.conf
COPY nginx.conf.fallback /etc/nginx/nginx.conf.fallback

COPY start.sh /start.sh

CMD ["/start.sh"]
27 changes: 27 additions & 0 deletions nginx/nginx.conf.fallback
@@ -0,0 +1,27 @@
# Basic configuration
user nginx;
worker_processes 1;
error_log /dev/stderr info;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
# Standard HTTP configuration with slight hardening
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
sendfile on;
keepalive_timeout 65;
server_tokens off;

server {
listen 80;

location /.well-known/acme-challenge {
proxy_pass http://admin:8081;
}
}
}
7 changes: 7 additions & 0 deletions nginx/start.sh
@@ -0,0 +1,7 @@
#!/bin/sh

if [[ ! -z ENABLE_CERTBOT && ! -f /certs/cert.pem ]]; then
cp /etc/nginx/nginx.conf.fallback /etc/nginx/nginx.conf
fi

nginx -g 'daemon off;'

0 comments on commit a0eeb76

Please sign in to comment.