Advertise the onion site on clearnet via Onion-Location header.
This commit is contained in:
@@ -19,6 +19,7 @@ NODE_ENV=development
|
||||
CORS_ORIGINS=http://localhost:5173,http://127.0.0.1:5173
|
||||
|
||||
CLEARNET_DOMAIN=localhost
|
||||
ONION_HOSTNAME=samplexxxxxxxxx.onion
|
||||
|
||||
JWT_SECRET=change-me-in-production
|
||||
JWT_EXPIRES_IN_MS=604800000 # 7 days
|
||||
|
||||
@@ -144,6 +144,14 @@ Save and exit the editor. Optional — run once manually to verify:
|
||||
./deploy/scripts/show-onion.sh
|
||||
```
|
||||
|
||||
Copy the hostname into `.env.prod` as `ONION_HOSTNAME`, then recreate nginx:
|
||||
|
||||
```bash
|
||||
docker compose --env-file .env.prod -f docker-compose.prod.yml up -d --force-recreate nginx
|
||||
```
|
||||
|
||||
Tor Browser will then show ".onion available" when visitors open the clearnet site over HTTPS.
|
||||
|
||||
## 9. Complete shop setup
|
||||
|
||||
1. Open the CMS on clearnet or onion (`/cms`).
|
||||
|
||||
@@ -18,5 +18,7 @@ server {
|
||||
ssl_certificate /etc/nginx/certs/live/${CLEARNET_DOMAIN}/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/certs/live/${CLEARNET_DOMAIN}/privkey.pem;
|
||||
|
||||
${ONION_LOCATION_HEADER}
|
||||
|
||||
include /etc/nginx/snippets/nullcart-locations-${SHOP_SURFACE}.conf;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,21 @@ render_server() {
|
||||
surface="$3"
|
||||
SHOP_SURFACE="$surface"
|
||||
export SHOP_SURFACE CLEARNET_DOMAIN BACKEND_PORT
|
||||
|
||||
if [ "$surface" = "clearnet" ]; then
|
||||
if [ -n "${ONION_HOSTNAME:-}" ]; then
|
||||
export ONION_LOCATION_HEADER="add_header Onion-Location \"http://${ONION_HOSTNAME}\$request_uri\";"
|
||||
else
|
||||
export ONION_LOCATION_HEADER=""
|
||||
fi
|
||||
|
||||
envsubst '${CLEARNET_DOMAIN} ${BACKEND_PORT} ${SHOP_SURFACE} ${ONION_LOCATION_HEADER}' \
|
||||
< "$template_path" \
|
||||
> "$output_path"
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
envsubst '${CLEARNET_DOMAIN} ${BACKEND_PORT} ${SHOP_SURFACE}' \
|
||||
< "$template_path" \
|
||||
> "$output_path"
|
||||
|
||||
Reference in New Issue
Block a user