[Bug]: --proxy-domain does not proxy when the host includes a port
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- node.js, typescript
- Domaine
- backend-api-design, networking
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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:mainat dda09f2
Steps to Reproduce
- Start code-server with
--proxy-domain example.com, with*.example.compointing at it, and run an app on port 3000. - 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 withproxy_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.
- Langage dominant
- TypeScript
- Étoiles
- 79.9k
- Forks
- 6.9k
- Merge moyen
- 20 h 21 min
- PR mergées (30 j)
- 51
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de coder/code-server
-
Error not trueOuverte
Difficulté 3/5 1-2 jours Accessibilité débutants 45/100
coder/code-server#8148 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 51/100
coder/code-server#8145 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 15/100
coder/code-server#8142 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: /healthz with a query string triggers a heartbeatPeut-être pris @adityajai119 l’a pris il y a 10 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 25/100
coder/code-server#8126 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 3/5 1-2 jours Accessibilité débutants 57/100
coder/code-server#8113 · 1 commentaire · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de coder/code-server
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
vercel-labs/ui#1066 ·
Les mainteneurs répondent en général sous 1 jour
-
fix(factory-cockpit): display active agent/actor name instead of verbose step name in run card badgeOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
ranxianglei/billion-context#7597 ·
Les mainteneurs répondent en général sous 1 jour
-
documentation target:powerpoint
Difficulté 1/5 Moins d'une heure Accessibilité débutants 76/100
tomast1337/PdfLapas#602 ·
Les mainteneurs répondent en général sous 1 jour
-
kubernetes-ingestor: fetchCRDMapping() runs even when crossplane.enabled is false, logging a 403 ERROR every runPeut-être pris @kc9ddi l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
TeraSky-OSS/backstage-plugins#228 ·