diff --git a/Local-Production-HTTPS-Simulation-Setup.md b/Local-Production-HTTPS-Simulation-Setup.md new file mode 100644 index 0000000..37bc764 --- /dev/null +++ b/Local-Production-HTTPS-Simulation-Setup.md @@ -0,0 +1,62 @@ +**Automatisch only serves the app over http and doesn't have out-of-the box https setup, so this guide shows how to setup a local https production simulation environment.** + +### **Note**: +We can't publish any Automatisch flows using this either local https or local http since Twilio won't be able to access the localhost, so this guide is kind of a pointless. But writing docs anyways just in case. + + + +### Create Self-Signed SSL Certs using OpenSSL: +- edit hosts file: `sudo nano /etc/hosts` +- create a new sitename and bind it to localhost. Something like: `127.0.0.1 shiloh_automatisch.local` +- save /etc/hosts file and exit +- cd to /shiloh_automatisch dir and create the .crt and .key files using openssl: `openssl req -x509 -newkey rsa:4096 -keyout https/certs/ssl.key -out certs/<>ssl.crt -days 365 -nodes -subj "/CN="` +- edit `/https/nginx/automatisch_letsencrypt_nginx.conf` file and add your site name, .crt and .key file names and save the file: +``` +events {} + +http { + server { + listen 443 ssl; + server_name ; + + ssl_certificate /etc/nginx/certs/; + ssl_certificate_key /etc/nginx/certs/; + + location / { + proxy_pass http://main:7757; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + } + } +} + +``` + +- In docker-compose.yml, uncomment the local https nginx service: +``` + # for local https development using self-signed certs via openssl + # nginx: + # image: nginx:latest + # depends_on: + # - main + # ports: + # - "443:443" + # volumes: + # - ./https/certs/${SSL_SELF_SIGNED_CRT}:/etc/nginx/certs/${SSL_SELF_SIGNED_CRT}:ro + # - ./https/certs/${SSL_SELF_SIGNED_KEY}:/etc/nginx/certs/${SSL_SELF_SIGNED_KEY}:ro + # - ./https/nginx/automatisch_self_signed_nginx.conf:/etc/nginx/conf.d/ + +``` +- Comment out production https letsencrypt nginx service +- Create a .env file at the project root and add your .crt and .key files as env vars: +``` +sudo nano .env +``` +``` +SSL_SELF_SIGNED_CRT=shiloh_automatisch.local.crt +SSL_SELF_SIGNED_KEY=shiloh_automatisch.local.key +``` +- Save .env file. Then run docker: `sudo docker compose up` +- You should now be able to pull up Automatisch locally at `https://` \ No newline at end of file