[Bug]: --proxy-domain does not proxy when the host includes a port

オープン
#8,128 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@adityajai119 がすでに取り組んでいます。

2026年11月13日 から。

  • #8129 @adityajai119 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript

調査の方向性

Read src/node/routes/domainProxy.ts and the maybeProxy() host matching logic, then compare it with the port handling in src/node/http.ts. Run the existing unit tests for domain proxying and check that hosts with and without a port proxy to the app, while proxy domains that include a port still work. The issue says a fix and test are already being submitted, so check for that work before starting.

索引モデルが issue の本文から書いたものです。

説明

Is there an existing issue for this?
  • I have searched the existing issues
OS/Web Information
  • Web Browser: not needed, reproduced with the unit tests
  • Local OS: Windows 11
  • Remote OS: Windows 11
  • Remote Architecture: x64
  • code-server --version: main at dda09f2
Steps to Reproduce
  1. Start code-server with --proxy-domain example.com, with *.example.com pointing at it, and run an app on port 3000.
  2. Open http://3000.example.com:8080/, that is, with code-server on a port other than 80 or 443. The same happens behind a reverse proxy that sends the host with a port, for example NGINX with proxy_set_header X-Forwarded-Host $host:$server_port; (as in #6166).
Expected

The request is proxied to port 3000, the same as 3000.example.com without a port, and as it was before 4.14.0.

Actual

The request is not proxied. code-server handles it itself, so the browser gets code-server or its login page instead of the app.

From the unit test setup on main (dda09f2), with --auth=none --proxy-domain=example.com and an app on port PORT that answers /wsup with "proxied":

GET /wsup  Host: PORT.example.com       -> 200 "proxied"
GET /wsup  Host: PORT.example.com:8443  -> 500 from code-server's own routes (the test setup cannot load VS Code)

Since #6225, maybeProxy() in src/node/routes/domainProxy.ts matches the host from getHost(), which keeps the port, against a pattern anchored at the end, ^(\d+)\.example\.com$. Before #6225 it dropped the port from the host first. getCookieDomain() in src/node/http.ts still drops the port when it compares the host with the proxy domains.

#7194 ran into this and worked around it by adding the port to the proxy domain (PROXY_DOMAIN=example.com:12345).

Logs

Not applicable.

Screenshot/Video

No response

Does this bug reproduce in native VS Code?

This cannot be tested in native VS Code

Does this bug reproduce in VS Code web?

This cannot be tested in VS Code web

Does this bug reproduce in GitHub Codespaces?

This cannot be tested in GitHub Codespaces

Are you accessing code-server over a secure context?
  • I am using a secure context.
Notes

The fix is to let the proxy domain pattern match an optional :port at the end of the host. Proxy domains that already include a port, like the workaround in #7194, keep working. I am opening a PR with the fix and a test.

AI-assisted: found and reproduced with an AI coding agent; the check above was run locally.

主要言語
TypeScript
スター
79.9k
フォーク
6.9k
平均マージ
20時間 21分
マージ済み PR(30日)
51

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

coder/code-server のほかの issue

coder/code-server の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。