daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Apr 27th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PEM_read_bio_X509_AUX("/etc/nginx/ssl/") failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line:Expecting: TRUSTED CERTIFICATE)
  2. 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)
  3.    
  4. FROM nginx:stable-alpine
  5.  
  6. ADD conf/nginx.conf /etc/nginx/nginx.conf
  7. ADD conf/service.conf /etc/nginx/conf.d/service.conf
  8.  
  9. RUN rm -rf /usr/share/nginx/html/*
  10. COPY --from=builder /usr/build/app/dist /usr/share/nginx/html
  11.  
  12. ADD script/entrypoint.sh /entrypoint.sh
  13. ADD script/le.sh /le.sh
  14.  
  15. RUN
  16.  rm /etc/nginx/conf.d/default.conf &&
  17.  chmod +x /entrypoint.sh &&
  18.  chmod +x /le.sh &&
  19.  apk add  --update certbot tzdata openssl &&
  20.  rm -rf /var/cache/apk/*
  21.  
  22. CMD ["/entrypoint.sh"]
  23.    
  24. #!/bin/sh
  25. echo "start nginx"
  26.  
  27. #set TZ
  28. cp /usr/share/zoneinfo/${TZ} /etc/localtime &&
  29. echo ${TZ} > /etc/timezone &&
  30.  
  31. #setup ssl keys
  32. 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}"
  33. SSL_KEY=/etc/nginx/ssl/${SSL_KEY}
  34. SSL_CERT=/etc/nginx/ssl/${SSL_CERT}
  35. SSL_CHAIN_CERT=/etc/nginx/ssl/${SSL_CHAIN_CERT}
  36.  
  37. mkdir -p /etc/nginx/conf.d
  38. mkdir -p /etc/nginx/ssl
  39.  
  40. #copy /etc/nginx/service*.conf if any of servcie*.conf mounted
  41. if [ -f /etc/nginx/service*.conf ]; then
  42.     cp -fv /etc/nginx/service*.conf /etc/nginx/conf.d/
  43. fi
  44.  
  45. #replace SSL_KEY, SSL_CERT and SSL_CHAIN_CERT by actual keys
  46. sed -i "s|SSL_KEY|${SSL_KEY}|g" /etc/nginx/conf.d/*.conf
  47. sed -i "s|SSL_CERT|${SSL_CERT}|g" /etc/nginx/conf.d/*.conf
  48. sed -i "s|SSL_CHAIN_CERT|${SSL_CHAIN_CERT}|g" /etc/nginx/conf.d/*.conf
  49.  
  50. #generate dhparams.pem
  51. if [ ! -f /etc/nginx/ssl/dhparams.pem ]; then
  52.     echo "make dhparams"
  53.     cd /etc/nginx/ssl
  54.     openssl dhparam -out dhparams.pem 2048
  55.     chmod 600 dhparams.pem
  56. fi
  57.  
  58. #disable ssl configuration and let it run without SSL
  59. mv -v /etc/nginx/conf.d /etc/nginx/conf.d.disabled
  60.  
  61. (
  62.  sleep 5 #give nginx time to start
  63.  echo "start letsencrypt updater"
  64.  while :
  65.  do
  66.     echo "trying to update letsencrypt ..."
  67.     /le.sh
  68.     rm -f /etc/nginx/conf.d/default.conf 2>/dev/null #remove default config, conflicting on 80
  69.     mv -v /etc/nginx/conf.d.disabled /etc/nginx/conf.d #enable
  70.     echo "reload nginx with ssl"
  71.     ls -al /etc/nginx/ssl
  72.     echo "key contents are - "
  73.     cat /etc/nginx/ssl/dhparams.pem  
  74.     nginx -t
  75.     nginx -s reload
  76.     sleep 60d
  77.  done
  78. ) &
  79.  
  80. nginx -g "daemon off;"
RAW Paste Data
Pastebin PRO SPRING Special!
Get 40% OFF Pastebin PRO accounts!
Top