Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
DOMAIN=local.example.com
HTTP_PORT=8080
HTTPS_PORT=8443
UPSTREAM_URL=http://host.docker.internal:3000
12 changes: 8 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:

env:
DOMAIN: sslproxy.stackpop.com
HTTP_PORT: 9080
HTTPS_PORT: 9443
UPSTREAM_URL: http://host.docker.internal:3000

jobs:
test:
Expand All @@ -24,7 +27,9 @@ jobs:
- name: Create .env
run: |
echo "DOMAIN=${{ env.DOMAIN }}" > .env
echo "UPSTREAM_URL=http://host.docker.internal:3000" >> .env
echo "HTTP_PORT=${{ env.HTTP_PORT }}" >> .env
echo "HTTPS_PORT=${{ env.HTTPS_PORT }}" >> .env
echo "UPSTREAM_URL=${{ env.UPSTREAM_URL }}" >> .env

- name: Add test domain to hosts
run: echo "127.0.0.1 ${{ env.DOMAIN }}" | sudo tee -a /etc/hosts
Expand Down Expand Up @@ -52,12 +57,11 @@ jobs:

- name: Test HTTP redirect
run: |
curl -s -o /dev/null -w "%{http_code}" http://${{ env.DOMAIN }}:8080 | grep -q "301\|308"
curl -s -o /dev/null -w "%{http_code}" http://${{ env.DOMAIN }}:${{ env.HTTP_PORT }} | grep -q "301\|308"

- name: Test HTTPS proxies to upstream
run: |
curl -s --cacert certs/${{ env.DOMAIN }}.rootCA.pem https://${{ env.DOMAIN }}:8443 | grep -q "nginx"

curl -s --cacert certs/${{ env.DOMAIN }}.rootCA.pem https://${{ env.DOMAIN }}:${{ env.HTTPS_PORT }} | grep -q "nginx"
- name: Show logs on failure
if: failure()
run: docker compose logs
Expand Down
6 changes: 4 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Environment variables (set in `.env`):

- `DOMAIN` - Domain name for SSL cert (default: `localhost`)
- `UPSTREAM_URL` - URL for your local app (default: `http://host.docker.internal:3000`)
- `HTTP_PORT` - HTTP port for redirects (default: `8080`)
- `HTTPS_PORT` - HTTPS port for proxy (default: `8443`)

## Files

Expand All @@ -51,5 +53,5 @@ Environment variables (set in `.env`):

## Ports

- `8080` → HTTP (redirects to HTTPS on 8443)
- `8443` → HTTPS (proxies to `${UPSTREAM_URL}`)
- `${HTTP_PORT}` (default `8080`) → HTTP (redirects to HTTPS)
- `${HTTPS_PORT}` (default `8443`) → HTTPS (proxies to `${UPSTREAM_URL}`)
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ Note (Linux): Requires Docker Engine 20.10+ for `host-gateway` support.
| Variable | Default | Description |
| -------------- | ---------------------------------- | ---------------------- |
| `DOMAIN` | `localhost` | Domain for SSL cert |
| `HTTP_PORT` | `8080` | HTTP port (redirects) |
| `HTTPS_PORT` | `8443` | HTTPS port (proxy) |
| `UPSTREAM_URL` | `http://host.docker.internal:3000` | URL for your local app |

## Ports

- `8080` - HTTP (redirects to HTTPS)
- `8443` - HTTPS
- `HTTP_PORT` (default `8080`) - HTTP (redirects to HTTPS)
- `HTTPS_PORT` (default `8443`) - HTTPS

## Layout

Expand Down
2 changes: 1 addition & 1 deletion config/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:80 {
redir https://{$DOMAIN:localhost}:8443{uri} permanent
redir https://{$DOMAIN:localhost}:{$HTTPS_PORT:8443}{uri} permanent
}

{$DOMAIN:localhost} {
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ services:
dockerfile: Dockerfile.caddy
container_name: ssl-proxy
ports:
- "8080:80"
- "8443:443"
- "${HTTP_PORT:-8080}:80"
- "${HTTPS_PORT:-8443}:443"
environment:
- DOMAIN=${DOMAIN:-localhost}
- UPSTREAM_URL=${UPSTREAM_URL:-http://host.docker.internal:3000}
- HTTPS_PORT=${HTTPS_PORT:-8443}
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
Expand Down