Spaces:
Running
Running
Upload Dockerfile
Browse files- Dockerfile +10 -1
Dockerfile
CHANGED
|
@@ -934,9 +934,18 @@ server {
|
|
| 934 |
access_log /dev/stdout;
|
| 935 |
error_log /dev/stderr warn;
|
| 936 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 937 |
# IDE(code-server):nginx 剝離 /ide/ 前綴後轉發到 code-server 根路徑
|
| 938 |
# proxy_pass 末尾帶 / 是關鍵:nginx 自動將 /ide/xxx 重寫為 /xxx 再轉發
|
| 939 |
-
# proxy_redirect:code-server 登錄後發 302 跳轉到 /,需重寫回 /ide/
|
|
|
|
| 940 |
location /ide/ {
|
| 941 |
proxy_pass http://127.0.0.1:PLACEHOLDER_CODE_SERVER_PORT/;
|
| 942 |
proxy_http_version 1.1;
|
|
|
|
| 934 |
access_log /dev/stdout;
|
| 935 |
error_log /dev/stderr warn;
|
| 936 |
|
| 937 |
+
# 關鍵:Cloudflare 做 SSL 終結,nginx 只收到 http 請求。
|
| 938 |
+
# 若 nginx 生成絕對 URL(如 301/302 Location),會帶上 http://host:PORT,
|
| 939 |
+
# 導致瀏覽器被重定向到帶明確端口的 http URL,被 Cloudflare 拒絕(400 Bad Request)。
|
| 940 |
+
# absolute_redirect off → 所有 nginx 內部重定向(含 proxy_redirect)輸出相對路徑
|
| 941 |
+
# port_in_redirect off → 禁止 nginx 在重定向 URL 中附加監聽端口
|
| 942 |
+
absolute_redirect off;
|
| 943 |
+
port_in_redirect off;
|
| 944 |
+
|
| 945 |
# IDE(code-server):nginx 剝離 /ide/ 前綴後轉發到 code-server 根路徑
|
| 946 |
# proxy_pass 末尾帶 / 是關鍵:nginx 自動將 /ide/xxx 重寫為 /xxx 再轉發
|
| 947 |
+
# proxy_redirect:code-server 登錄後發 302 跳轉到 /,需重寫回 /ide/
|
| 948 |
+
# 由於 absolute_redirect off,這裡輸出的是相對路徑,不帶 scheme/host/port
|
| 949 |
location /ide/ {
|
| 950 |
proxy_pass http://127.0.0.1:PLACEHOLDER_CODE_SERVER_PORT/;
|
| 951 |
proxy_http_version 1.1;
|