Skip to content

[Feat]: Support {{host}} in proxy-uri argument #6218

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
hulknsmash opened this issue May 17, 2023 · 4 comments · Fixed by #6225
Closed

[Feat]: Support {{host}} in proxy-uri argument #6218

hulknsmash opened this issue May 17, 2023 · 4 comments · Fixed by #6225
Labels
enhancement Some improvement that isn't a feature

Comments

@hulknsmash
Copy link

What is your suggestion?

Currently, we can use {{port}}.domain.com as proxy uri to replace domain.com/proxy/{{port}} pattern.
It would be nice to support --proxy-uri={{port}}.{{host}}, where {{host}} will be replaced will be replaced by current domain.

Why do you want this feature?

I'm using ngrok to access my code-server outside of home, and it doesn't provide persistent subdomain on free plan. Allowing {{port}}.{{host}} will easily allow this instead of requiring manual configuration on every restart.

Are there any workarounds to get this functionality today?

Manually update the host, every time ngrok changes the url.

Are you interested in submitting a PR for this?

I don't have any test environment setup for coder, but the changes need to be around this line:
https://github.com/coder/code-server/blob/main/patches/proxy-uri.diff#L128

@hulknsmash hulknsmash added the enhancement Some improvement that isn't a feature label May 17, 2023
@code-asher
Copy link
Member

Cool idea, I bet we could also support #6195 with this.

@smerschjohann
Copy link
Contributor

Any help wanted to implement this feature? I have use for that as well (well not this one, but the other one you referenced). I would change it, in the way that you can simply define anything you want while supporting matchers like this (not a regex, just wildcard match):

  • code-{{ port }}.something-specific.tld => fixed domain, port at any position
  • port-{{ port }}.* => port at any position, any host would match.
  • {{ port }}.portforwards.* => port at any position, even one domain hierarchy down

There could also be a host variable, but I'm not sure if there is already such information somewhere in the configuration. That cannot be determined automatically, except after startup someone visits the editor and at that point this variable is set. But I'm not sure if there would be any benefit of doing so.

The domain shouldn't be resolved to the IP of code-server in the first place if it should no reach code-server. And even if it does in an unintented way, I don't see a security problem here. The proxy requires authentication anyway.

@smerschjohann
Copy link
Contributor

Ah, we still need the host info for the PORTS tab... ok in that case it might really be a better idea to use {{ host }} instead of *, while in the matchers that would just be interpreted in the same way as I described above.

@code-asher
Copy link
Member

Help is welcome for sure!

The current syntax for --domain-proxy is *.domain.tld or domain.tld so we should keep those as possibilities for backwards compatibility.

The cases you describe make sense to me!

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