Add Local Production HTTPS Simulation Setup

Linden Crandall 2025-02-06 22:55:18 +00:00
parent 86c276ed13
commit 589d042ae9

@ -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=<YOUR LOCAL SITE NAME i.e. shiloh_automatisch.local>"`
- 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 <ADD LOCAL HOSTNAME HERE i.e. shiloh_automatisch.local>;
ssl_certificate /etc/nginx/certs/<ADD YOUR .CRT FILE HERE>;
ssl_certificate_key /etc/nginx/certs/<ADD YOUR .KEY FILE HERE>;
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://<YOUR SITE NAME>`