From 655ebc199c75a32efa7c60b5dd4bd9196c5904b3 Mon Sep 17 00:00:00 2001 From: jethro Date: Thu, 12 Sep 2024 10:43:10 +0800 Subject: [PATCH] Supplements the Reverse Proxy configuration instructions for docker deployment. Modify docker-compose to expose port 3000 --- docker-compose.yml | 2 ++ docs/local-dev.md | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 17829260..4d5d68b6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,8 @@ services: volumes: - ./server/:/home/node/app command: ash -c "npm i && node index.js" + ports: + - "3000:3000" nginx: build: context: ./docker/ diff --git a/docs/local-dev.md b/docs/local-dev.md index 39f19d9c..bd07e5cd 100644 --- a/docs/local-dev.md +++ b/docs/local-dev.md @@ -52,7 +52,21 @@ The site is served on `https://:443`. ## Deployment Notes The client expects the server at http(s)://your.domain/server. -When serving the node server behind a proxy, the `X-Forwarded-For` header has to be set by the proxy. Otherwise, all clients that are served by the proxy will be mutually visible. +When serving the node server behind a proxy, you need to configure the proxy separately for the node server. For nginx the configuration should look like this: +``` +location ^~ /server { + proxy_pass http://127.0.0.1:3000; + 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 REMOTE-HOST $remote_addr; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + add_header Cache-Control no-cache; +} +``` + +Tips: the `X-Forwarded-For` header has to be set by the proxy. Otherwise, all clients that are served by the proxy will be mutually visible. By default, the server listens on port 3000.