You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
942 B

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. #!/usr/bin/env bash
  2. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3. cd $DIR
  4. cd ../..
  5. unset DIR
  6. # create certificate pair
  7. sudo apt-get install -y openssl
  8. openssl req -new -newkey rsa:4096 -sha256 -nodes -x509 -keyout ./nginx/cert.key -out ./nginx/cert.crt \
  9. -subj "/C=US/ST=StateCode/L=LocationName/O=OrganizationName/OU=OrganizationUnit/CN=doccano.herokuapp.com"
  10. # define cert paths inside container
  11. ssl_cert="/certs/cert.crt"
  12. ssl_cert_key="/certs/cert.key"
  13. # edit default.conf
  14. sed -i "s|listen 80;|listen 443 ssl;\n ssl_certificate $ssl_cert;\n ssl_certificate_key $ssl_cert_key;|g" nginx/default.conf
  15. # edit nginx Dockerfile
  16. echo "RUN mkdir -p /certs/" >> nginx/Dockerfile
  17. echo "COPY nginx/cert.key /certs/cert.key" >> nginx/Dockerfile
  18. echo "COPY nginx/cert.crt /certs/cert.crt" >> nginx/Dockerfile
  19. # edit published port
  20. sed -i "s|- 80:80|- 443:443|g" docker-compose.prod.yml
  21. echo "Switched to HTTPS"