Skip to content

Support proxying ports without separate sub-domains #6195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
502647092 opened this issue May 8, 2023 · 6 comments · Fixed by #6225
Closed
4 tasks done

Support proxying ports without separate sub-domains #6195

502647092 opened this issue May 8, 2023 · 6 comments · Fixed by #6225
Labels
enhancement Some improvement that isn't a feature

Comments

@502647092
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: EDGE
  • Local OS: Windows
  • Remote OS: Linux
  • Remote Architecture: x64
  • code-server --version: 4.12.0

Steps to Reproduce

config env
PROXY_DOMAIN: domain.ltd
VSCODE_PROXY_URI: https://{{port}}-code.domain.ltd

open https://{{port}}-code.domain.ltd redirect to coder-server

Expected

redirect to loca proxy port

Actual

redirect to coder-server

Logs

No response

Screenshot/Video

No response

Does this issue happen in VS Code or GitHub Codespaces?

  • I cannot reproduce this in VS Code.
  • I cannot reproduce this in GitHub Codespaces.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

#5311

const parts = domain.split(".")
// There must be an exact match.
const port = parts.shift()
const proxyDomain = parts.join(".")
if (!port || !req.args["proxy-domain"].includes(proxyDomain)) {
return undefined
}

maybe can use regex to match port
example
VSCODE_PROXY_URI {{port}}-code.domain.ltd
5140-code.domain.ltd match port to 5140

@502647092 502647092 added bug Something isn't working triage This issue needs to be triaged by a maintainer labels May 8, 2023
@502647092 502647092 changed the title [Bug]: domain proxy not support {{port}}-code.domain.ltd [Bug]: domain proxy not support match VSCODE_PROXY_URI {{port}} May 8, 2023
@code-asher
Copy link
Member

Ah yeah the subdomain proxy requires that the port be the first and only part of the sub-domain, so something like {{port}}.code.domain.tld (with proxy-domain set to code.domain.tld) or {{port}}.domain.tld (with proxy-domain set to domain.tld) instead would work.

@502647092
Copy link
Author

Ah yeah the subdomain proxy requires that the port be the first and only part of the sub-domain, so something like {{port}}.code.domain.tld (with proxy-domain set to code.domain.tld) or {{port}}.domain.tld (with proxy-domain set to domain.tld) instead would work.

Perhaps we can compromise and adopt the method I suggested, which can eliminate the need to apply for another wildcard SSL certificate.

@code-asher
Copy link
Member

Sure, that seems like a good reason.

@code-asher code-asher added enhancement Some improvement that isn't a feature and removed bug Something isn't working triage This issue needs to be triaged by a maintainer labels May 11, 2023
@code-asher code-asher changed the title [Bug]: domain proxy not support match VSCODE_PROXY_URI {{port}} Support proxying ports without separate sub-domains May 11, 2023
@code-asher
Copy link
Member

code-asher commented May 31, 2023

This will make it into the next release but I am not sure it actually solves this particular problem. You still need separate (sub)domains for every single port.

5140-code.domain.ltd
5141-code.domain.ltd
5142-code.domain.ltd

This still requires a wildcard cert right?

The only way to not require multiple domains is to use the path-based proxy.

@oruharo
Copy link

oruharo commented May 31, 2023

I need it to run multiple code-servers on k8s.

@code-asher
Copy link
Member

Ahhh I see! That use case makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Some improvement that isn't a feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants