SHARE
TWEET
Untitled
a guest
Apr 27th, 2018
50
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- PEM_read_bio_X509_AUX("/etc/nginx/ssl/") failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line:Expecting: TRUSTED CERTIFICATE)
- nginx: [emerg] PEM_read_bio_X509_AUX("/etc/nginx/ssl/") failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line:Expecting: TRUSTED CERTIFICATE)
- FROM nginx:stable-alpine
- ADD conf/nginx.conf /etc/nginx/nginx.conf
- ADD conf/service.conf /etc/nginx/conf.d/service.conf
- RUN rm -rf /usr/share/nginx/html/*
- COPY --from=builder /usr/build/app/dist /usr/share/nginx/html
- ADD script/entrypoint.sh /entrypoint.sh
- ADD script/le.sh /le.sh
- RUN
- rm /etc/nginx/conf.d/default.conf &&
- chmod +x /entrypoint.sh &&
- chmod +x /le.sh &&
- apk add --update certbot tzdata openssl &&
- rm -rf /var/cache/apk/*
- CMD ["/entrypoint.sh"]
- #!/bin/sh
- echo "start nginx"
- #set TZ
- cp /usr/share/zoneinfo/${TZ} /etc/localtime &&
- echo ${TZ} > /etc/timezone &&
- #setup ssl keys
- echo "ssl_key=${SSL_KEY:=le-key.pem}, ssl_cert=${SSL_CERT:=le-crt.pem}, ssl_chain_cert=${SSL_CHAIN_CERT:=le-chain-crt.pem}"
- SSL_KEY=/etc/nginx/ssl/${SSL_KEY}
- SSL_CERT=/etc/nginx/ssl/${SSL_CERT}
- SSL_CHAIN_CERT=/etc/nginx/ssl/${SSL_CHAIN_CERT}
- mkdir -p /etc/nginx/conf.d
- mkdir -p /etc/nginx/ssl
- #copy /etc/nginx/service*.conf if any of servcie*.conf mounted
- if [ -f /etc/nginx/service*.conf ]; then
- cp -fv /etc/nginx/service*.conf /etc/nginx/conf.d/
- fi
- #replace SSL_KEY, SSL_CERT and SSL_CHAIN_CERT by actual keys
- sed -i "s|SSL_KEY|${SSL_KEY}|g" /etc/nginx/conf.d/*.conf
- sed -i "s|SSL_CERT|${SSL_CERT}|g" /etc/nginx/conf.d/*.conf
- sed -i "s|SSL_CHAIN_CERT|${SSL_CHAIN_CERT}|g" /etc/nginx/conf.d/*.conf
- #generate dhparams.pem
- if [ ! -f /etc/nginx/ssl/dhparams.pem ]; then
- echo "make dhparams"
- cd /etc/nginx/ssl
- openssl dhparam -out dhparams.pem 2048
- chmod 600 dhparams.pem
- fi
- #disable ssl configuration and let it run without SSL
- mv -v /etc/nginx/conf.d /etc/nginx/conf.d.disabled
- (
- sleep 5 #give nginx time to start
- echo "start letsencrypt updater"
- while :
- do
- echo "trying to update letsencrypt ..."
- /le.sh
- rm -f /etc/nginx/conf.d/default.conf 2>/dev/null #remove default config, conflicting on 80
- mv -v /etc/nginx/conf.d.disabled /etc/nginx/conf.d #enable
- echo "reload nginx with ssl"
- ls -al /etc/nginx/ssl
- echo "key contents are - "
- cat /etc/nginx/ssl/dhparams.pem
- nginx -t
- nginx -s reload
- sleep 60d
- done
- ) &
- nginx -g "daemon off;"
RAW Paste Data

