Compare commits

...
2 Commits
Author SHA1 Message Date
wuyanwanwu b73027ed9d Document n8n reverse proxy settings 2026-08-17 20:33:24 +08:00
wuyanwanwu 9490a1ce54 Bind news app to localhost for reverse proxy 2026-08-17 20:32:41 +08:00
6 changed files with 13 additions and 6 deletions
+1
View File
@@ -1,6 +1,7 @@
# Application # Application
APP_ENV=production APP_ENV=production
APP_PORT= APP_PORT=
APP_HOST=0.0.0.0
APP_BASE_URL= APP_BASE_URL=
APP_SECRET_KEY= APP_SECRET_KEY=
APP_ADMIN_TOKEN= APP_ADMIN_TOKEN=
+2
View File
@@ -46,6 +46,8 @@ ssh -N -L 15432:127.0.0.1:5432 <ssh-user>@<server-ip>
Linux 云服务器上推荐使用 `docker-compose.host-network.yml`SSH 隧道监听宿主机 `127.0.0.1:15432`,网页容器使用宿主机网络,`.env` 中填写 `PGHOST=127.0.0.1``PGPORT=15432`。这样不会把数据库隧道端口暴露到公网。模板见 `deploy/daily-news-db-tunnel.service.example` Linux 云服务器上推荐使用 `docker-compose.host-network.yml`SSH 隧道监听宿主机 `127.0.0.1:15432`,网页容器使用宿主机网络,`.env` 中填写 `PGHOST=127.0.0.1``PGPORT=15432`。这样不会把数据库隧道端口暴露到公网。模板见 `deploy/daily-news-db-tunnel.service.example`
网页服务可由 Nginx 代理到宿主机本地端口。使用 `docker-compose.host-network.yml` 时,覆盖配置会让网页只监听 `127.0.0.1:3100`;不要直接把 3100 暴露给公网。
## 配置 ## 配置
复制 `.env.example``.env`,再在服务器上填写实际值。仓库中不提交 `.env`、密码、SMTP 授权码或 SSH 私钥。 复制 `.env.example``.env`,再在服务器上填写实际值。仓库中不提交 `.env`、密码、SMTP 授权码或 SSH 私钥。
+2
View File
@@ -4,3 +4,5 @@ services:
web: web:
network_mode: host network_mode: host
ports: [] ports: []
environment:
APP_HOST: 127.0.0.1
+1 -1
View File
@@ -5,6 +5,6 @@ services:
env_file: env_file:
- .env - .env
ports: ports:
- "3100:3100" - "127.0.0.1:3100:3100"
extra_hosts: extra_hosts:
- "host.docker.internal:host-gateway" - "host.docker.internal:host-gateway"
+5 -4
View File
@@ -2,13 +2,14 @@
# Do not change this value after n8n has stored credentials. # Do not change this value after n8n has stored credentials.
N8N_ENCRYPTION_KEY= N8N_ENCRYPTION_KEY=
# Initial access is through an SSH tunnel, so keep n8n on localhost. # Nginx terminates HTTPS; n8n itself listens on local HTTP only.
N8N_HOST=127.0.0.1 N8N_HOST=n8n.example.com
N8N_PORT=5678 N8N_PORT=5678
N8N_LISTEN_ADDRESS=127.0.0.1 N8N_LISTEN_ADDRESS=127.0.0.1
N8N_PROTOCOL=http N8N_PROTOCOL=http
N8N_EDITOR_BASE_URL=http://127.0.0.1:5678 N8N_EDITOR_BASE_URL=https://n8n.example.com
N8N_SECURE_COOKIE=false WEBHOOK_URL=https://n8n.example.com/
N8N_SECURE_COOKIE=true
TZ=Asia/Shanghai TZ=Asia/Shanghai
GENERIC_TIMEZONE=Asia/Shanghai GENERIC_TIMEZONE=Asia/Shanghai
+2 -1
View File
@@ -6,6 +6,7 @@ const { URL } = require('url');
const { Pool } = require('pg'); const { Pool } = require('pg');
const PORT = Number(process.env.APP_PORT || 3000); const PORT = Number(process.env.APP_PORT || 3000);
const HOST = process.env.APP_HOST || '0.0.0.0';
const PUBLIC_DIR = path.join(__dirname, 'public'); const PUBLIC_DIR = path.join(__dirname, 'public');
const ADMIN_TOKEN = process.env.APP_ADMIN_TOKEN || ''; const ADMIN_TOKEN = process.env.APP_ADMIN_TOKEN || '';
@@ -306,7 +307,7 @@ const server = http.createServer(async (req, res) => {
} }
}); });
server.listen(PORT, '0.0.0.0', () => { server.listen(PORT, HOST, () => {
console.log(`Daily news digest web listening on ${PORT}`); console.log(`Daily news digest web listening on ${PORT}`);
}); });