Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:memo: Document reverse proxy Host header requirements https://github.com/siyuan-note/siyuan/issues/19700

Daniel0ca46c216278
diff --git a/README.ja.md b/README.ja.md
index 06cd74fd0c..47cf850bc4 100644
--- a/README.ja.md
+++ b/README.ja.md
@@ -278,6 +278,7 @@ chown -R 1001:1002 /siyuan/workspace
NGINXリバースプロキシを使用してポート6806を隠します。注意点:
- WebSocketリバースプロキシ `/ws` を設定します
+- 通常のリクエストと `/ws` の両方で、ポートを含む元の `Host` ヘッダーを保持してください。NGINX の両方のプロキシ設定に `proxy_set_header Host $http_host;` を指定します。`$host` を使用すると標準以外のポート(例:`8443`)が失われ、Origin の検証に失敗する場合があります。その結果、ログイン後にロゴ画面で再読み込みを繰り返す、API が `401` を返す、WebSocket 接続に失敗するなどの問題が発生します
#### 注意
diff --git a/README.md b/README.md
index 8fdba897f3..75f93001fe 100644
--- a/README.md
+++ b/README.md
@@ -284,6 +284,7 @@ If you use custom `PUID` and `PGID` values, the entrypoint script will ensure th
Use an NGINX reverse proxy to hide port 6806. Please note:
- Configure the WebSocket reverse proxy for `/ws`
+- Preserve the original `Host` header, including the port, for both regular requests and `/ws`. In NGINX, configure `proxy_set_header Host $http_host;` in both proxy locations. Using `$host` drops non-standard ports (such as `8443`), which can cause Origin validation to fail, leaving the page stuck on the logo with repeated reloads, API responses of `401`, or failed WebSocket connections
#### Note
diff --git a/README.tr.md b/README.tr.md
index d555fd5256..d92033a9ce 100644
--- a/README.tr.md
+++ b/README.tr.md
@@ -279,6 +279,7 @@ Eğer özel `PUID` ve `PGID` değerleri kullanıyorsan, `entrypoint` betiği kon
Port 6806’yı gizlemek için NGINX ters proxy (reverse proxy) kullan. Dikkat edilmesi gerekenler:
- WebSocket ters proxy’sini `/ws` yoluna göre yapılandır.
+- Hem normal isteklerde hem de `/ws` için port dahil özgün `Host` başlığını koruyun. NGINX yapılandırmasında her iki proxy konumuna da `proxy_set_header Host $http_host;` ekleyin. `$host` kullanımı standart dışı portları (örneğin `8443`) kaldırır; bu da Origin doğrulamasının başarısız olmasına, girişten sonra logoda takılıp sayfanın sürekli yenilenmesine, API isteklerinin `401` yanıtı vermesine veya WebSocket bağlantılarının başarısız olmasına neden olabilir
#### Notlar
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 6ef4474cc3..6d1678875e 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -283,6 +283,7 @@ chown -R 1001:1002 /siyuan/workspace
使用 NGINX 反向代理可以隐藏 6806 端口,请注意:
- 配置 WebSocket 反代 `/ws`
+- 普通请求和 `/ws` 的反向代理都需要保留原始 `Host` 请求头及端口,在 NGINX 的两处代理配置中均设置 `proxy_set_header Host $http_host;`。使用 `$host` 会丢失非标准端口(如 `8443`),可能导致来源校验失败,表现为登录后停留在 LOGO 并反复刷新、接口返回 `401` 或 WebSocket 连接失败
#### 注意
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201227201128-m1wrouw.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201227201128-m1wrouw.sy
index 0b14be576f..fd6ec5430a 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201227201128-m1wrouw.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201227201128-m1wrouw.sy
@@ -6,7 +6,7 @@
"id": "20201227201128-m1wrouw",
"title": "Docker hosting",
"type": "doc",
- "updated": "20260918190000"
+ "updated": "20260921003419"
},
"Children": [
{
@@ -644,7 +644,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20210930092059-ifrr6wz",
- "updated": "20210930092059"
+ "updated": "20260921003419"
},
"Children": [
{
@@ -673,7 +673,7 @@
"ListData": {},
"Properties": {
"id": "20210930092059-34ljyge",
- "updated": "20211112103356"
+ "updated": "20260921003419"
},
"Children": [
{
@@ -708,6 +708,88 @@
]
}
]
+ },
+ {
+ "ID": "20260921003419-ozfsnu8",
+ "Type": "NodeListItem",
+ "ListData": {
+ "BulletChar": 42,
+ "Marker": "Kg=="
+ },
+ "Children": [
+ {
+ "ID": "20260921003419-hvawzrd",
+ "Type": "NodeParagraph",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Preserve the original "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "Host"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " header, including the port, for both regular requests and "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "/ws"
+ },
+ {
+ "Type": "NodeText",
+ "Data": ". In NGINX, configure "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "proxy_set_header Host $http_host;"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " in both proxy locations. Using "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "$host"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " drops non-standard ports (such as "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "8443"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "), which can cause Origin validation to fail, leaving the page stuck on the logo with repeated reloads, API responses of "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "401"
+ },
+ {
+ "Type": "NodeText",
+ "Data": ", or failed WebSocket connections"
+ }
+ ],
+ "Properties": {
+ "id": "20260921003419-hvawzrd",
+ "updated": "20260921003419"
+ }
+ }
+ ],
+ "Properties": {
+ "id": "20260921003419-ozfsnu8",
+ "updated": "20260921003419"
+ }
}
]
},
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201227173504-847cs1q.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201227173504-847cs1q.sy
index f3cfb4350f..84a48b56e0 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201227173504-847cs1q.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201227173504-847cs1q.sy
@@ -6,7 +6,7 @@
"id": "20201227173504-847cs1q",
"title": "Docker 伺服",
"type": "doc",
- "updated": "20260918190000"
+ "updated": "20260921003419"
},
"Children": [
{
@@ -648,7 +648,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20210930091350-4oy2gq8",
- "updated": "20210930091414"
+ "updated": "20260921003419"
},
"Children": [
{
@@ -677,7 +677,7 @@
"ListData": {},
"Properties": {
"id": "20210930091550-c9aemmk",
- "updated": "20211112103359"
+ "updated": "20260921003419"
},
"Children": [
{
@@ -716,6 +716,88 @@
]
}
]
+ },
+ {
+ "ID": "20260921003419-qnv6oha",
+ "Type": "NodeListItem",
+ "ListData": {
+ "BulletChar": 42,
+ "Marker": "Kg=="
+ },
+ "Children": [
+ {
+ "ID": "20260921003419-iwqwtrh",
+ "Type": "NodeParagraph",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "普通请求和 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "/ws"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 的反向代理都需要保留原始 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "Host"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 请求头及端口,在 NGINX 的两处代理配置中均设置 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "proxy_set_header Host $http_host;"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "。使用 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "$host"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 会丢失非标准端口(如 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "8443"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "),可能导致来源校验失败,表现为登录后停留在 LOGO 并反复刷新、接口返回 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "401"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 或 WebSocket 连接失败"
+ }
+ ],
+ "Properties": {
+ "id": "20260921003419-iwqwtrh",
+ "updated": "20260921003419"
+ }
+ }
+ ],
+ "Properties": {
+ "id": "20260921003419-qnv6oha",
+ "updated": "20260921003419"
+ }
}
]
},
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122459-08mi5cq.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122459-08mi5cq.sy
index 1c769772d6..f578739849 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122459-08mi5cq.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122459-08mi5cq.sy
@@ -6,7 +6,7 @@
"id": "20211226122459-08mi5cq",
"title": "Docker 伺服",
"type": "doc",
- "updated": "20260918190000"
+ "updated": "20260921003419"
},
"Children": [
{
@@ -610,7 +610,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20211226122519-wwlpn5g",
- "updated": "20211226011647"
+ "updated": "20260921003419"
},
"Children": [
{
@@ -639,7 +639,7 @@
"ListData": {},
"Properties": {
"id": "20211226122519-kh6qira",
- "updated": "20211228132828"
+ "updated": "20260921003419"
},
"Children": [
{
@@ -678,6 +678,88 @@
]
}
]
+ },
+ {
+ "ID": "20260921003419-sn7b4ld",
+ "Type": "NodeListItem",
+ "ListData": {
+ "BulletChar": 42,
+ "Marker": "Kg=="
+ },
+ "Children": [
+ {
+ "ID": "20260921003419-w31hwdt",
+ "Type": "NodeParagraph",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "一般請求和 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "/ws"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 的反向代理都需要保留原始 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "Host"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 請求標頭及連接埠,在 NGINX 的兩處代理設定中均設定 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "proxy_set_header Host $http_host;"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "。使用 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "$host"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 會遺失非標準連接埠(如 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "8443"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "),可能導致來源驗證失敗,表現為登入後停留在 LOGO 並反覆重新整理、介面回傳 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "401"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 或 WebSocket 連線失敗"
+ }
+ ],
+ "Properties": {
+ "id": "20260921003419-w31hwdt",
+ "updated": "20260921003419"
+ }
+ }
+ ],
+ "Properties": {
+ "id": "20260921003419-sn7b4ld",
+ "updated": "20260921003419"
+ }
}
]
},
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-f16hpct.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-f16hpct.sy
index 729619c002..04907c0fc1 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-f16hpct.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-f16hpct.sy
@@ -7,7 +7,7 @@
"id": "20240530101000-f16hpct",
"title": "Docker サーバー",
"type": "doc",
- "updated": "20260918190000"
+ "updated": "20260921003419"
},
"Children": [
{
@@ -740,7 +740,7 @@
"Properties": {
"ID": "20240530101000-8reh0fr",
"id": "20240530101000-8viay1g",
- "updated": "20240530101000"
+ "updated": "20260921003419"
},
"Children": [
{
@@ -771,7 +771,7 @@
"Properties": {
"ID": "20240530101000-vxly6p7",
"id": "20240530101000-tzkk9tn",
- "updated": "20240530101000"
+ "updated": "20260921003419"
},
"Children": [
{
@@ -812,6 +812,88 @@
]
}
]
+ },
+ {
+ "ID": "20260921003419-g3s2ee9",
+ "Type": "NodeListItem",
+ "ListData": {
+ "BulletChar": 42,
+ "Marker": "Kg=="
+ },
+ "Children": [
+ {
+ "ID": "20260921003419-rwf16da",
+ "Type": "NodeParagraph",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "通常のリクエストと "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "/ws"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " の両方で、ポートを含む元の "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "Host"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " ヘッダーを保持してください。NGINX の両方のプロキシ設定に "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "proxy_set_header Host $http_host;"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を指定します。"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "$host"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を使用すると標準以外のポート(例:"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "8443"
+ },
+ {
+ "Type": "NodeText",
+ "Data": ")が失われ、Origin の検証に失敗する場合があります。その結果、ログイン後にロゴ画面で再読み込みを繰り返す、API が "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "code",
+ "TextMarkTextContent": "401"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を返す、WebSocket 接続に失敗するなどの問題が発生します"
+ }
+ ],
+ "Properties": {
+ "id": "20260921003419-rwf16da",
+ "updated": "20260921003419"
+ }
+ }
+ ],
+ "Properties": {
+ "id": "20260921003419-g3s2ee9",
+ "updated": "20260921003419"
+ }
}
]
},