@@ -11,90 +11,74 @@ A Dockerized Caddy reverse proxy with automatic SSL certificate generation for l
1111
1212## Quick Start
1313
14- 1 . Configure your domain in ` .env ` :
14+ 1 . Create an env file for your domain (e.g., ` .env.local.example.com ` ) :
1515
1616 ```
1717 DOMAIN=local.example.com
1818 UPSTREAM_URL=http://host.docker.internal:3000
19+ HTTP_PORT=8080
20+ HTTPS_PORT=8443
1921 ```
2022
21- > [ !WARNING]
22- > ` UPSTREAM_URL ` must include the scheme and port.
23+ > [ !WARNING]
24+ > ` UPSTREAM_URL ` must include the scheme and port.
2325
24- 2 . Add your domain to the hosts file:
25-
26- ** macOS/Linux:**
27- Edit ` /etc/hosts `
26+ 2 . Add your domain to hosts file:
2827
2928 ``` bash
29+ # macOS/Linux
3030 sudo sh -c ' echo "127.0.0.1 local.example.com" >> /etc/hosts'
31- ```
3231
33- ** Windows (PowerShell as Administrator):**
34- Edit ` C:\Windows\System32\drivers\etc\hosts `
35-
36- ``` powershell
32+ # Windows (PowerShell as Admin)
3733 Add-Content -Path C:\W indows\S ystem32\d rivers\e tc\h osts -Value " 127.0.0.1 local.example.com"
3834 ```
3935
40- 3 . Generate certificates (first time only) :
36+ 3 . Generate certificates:
4137
4238 ``` bash
43- docker compose --profile setup run --rm mkcert
39+ docker compose --env-file .env.local.example.com -- profile setup run --rm mkcert
4440 ```
4541
46- 4 . Install the CA certificate (one-time):
47-
48- Replace ` local.example.com ` with your configured domain.
49-
50- ** macOS:**
42+ 4 . Install CA certificate (one-time per domain):
5143
5244 ``` bash
45+ # macOS
5346 sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ./certs/local.example.com.rootCA.pem
54- ```
55-
56- ** Linux (Debian/Ubuntu):**
5747
58- ``` bash
59- sudo cp ./certs/local.example.com.rootCA.pem /usr/local/share/ca-certificates/local.example.com.crt
60- sudo update-ca-certificates
61- ```
62-
63- ** Linux (Fedora/RHEL):**
64-
65- ``` bash
66- sudo cp ./certs/local.example.com.rootCA.pem /etc/pki/ca-trust/source/anchors/local.example.com.pem
67- sudo update-ca-trust
68- ```
48+ # Linux (Debian/Ubuntu)
49+ sudo cp ./certs/local.example.com.rootCA.pem /usr/local/share/ca-certificates/local.example.com.crt && sudo update-ca-certificates
6950
70- ** Linux (Arch):**
51+ # Linux (Fedora/RHEL)
52+ sudo cp ./certs/local.example.com.rootCA.pem /etc/pki/ca-trust/source/anchors/local.example.com.pem && sudo update-ca-trust
7153
72- ``` bash
54+ # Linux (Arch)
7355 sudo trust anchor ./certs/local.example.com.rootCA.pem
74- ```
7556
76- ** Windows (PowerShell as Administrator):**
77-
78- ``` powershell
57+ # Windows (PowerShell as Admin)
7958 Import-Certificate -FilePath .\c erts\l ocal.example.com.rootCA.pem -CertStoreLocation Cert:\L ocalMachine\R oot
8059 ```
8160
82- If ` .pem ` import fails, convert to ` .cer ` first:
83-
84- ``` powershell
85- openssl x509 -in .\certs\local.example.com.rootCA.pem -out .\certs\local.example.com.rootCA.cer
86- Import-Certificate -FilePath .\certs\local.example.com.rootCA.cer -CertStoreLocation Cert:\LocalMachine\Root
87- ```
88-
89615 . Start the proxy:
9062
9163 ``` bash
92- docker compose up -d
64+ docker compose --env-file .env.local.example.com up -d
9365 ```
9466
95676 . Visit: ` https://local.example.com:8443 `
9668
97- Note (Linux): Requires Docker Engine 20.10+ for ` host-gateway ` support.
69+ > [ !NOTE]
70+ > Linux requires Docker Engine 20.10+ for ` host-gateway ` support.
71+
72+ ## Running Multiple Domains
73+
74+ Run multiple instances by creating separate env files with different ports:
75+
76+ ``` bash
77+ docker compose --env-file .env.local.example.com up -d
78+ docker compose --env-file .env.local.another.com up -d
79+ ```
80+
81+ Each instance runs in its own project namespace based on the domain name.
9882
9983## Configuration
10084
@@ -105,11 +89,6 @@ Note (Linux): Requires Docker Engine 20.10+ for `host-gateway` support.
10589| ` HTTPS_PORT ` | ` 8443 ` | HTTPS port (proxy) |
10690| ` UPSTREAM_URL ` | ` http://host.docker.internal:3000 ` | URL for your local app |
10791
108- ## Ports
109-
110- - ` HTTP_PORT ` (default ` 8080 ` ) - HTTP (redirects to HTTPS)
111- - ` HTTPS_PORT ` (default ` 8443 ` ) - HTTPS
112-
11392## Layout
11493
11594```
0 commit comments