-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[caddy] proxy requests to port locations through ws proxy #4419
Conversation
c6d6127
to
e001a06
Compare
@@ -216,7 +216,11 @@ https://*.*.{$GITPOD_DOMAIN} { | |||
|
|||
@workspace_port header_regexp host Host ^(webview-|browser-|extensions-)?(?P<workspacePort>[0-9]{2,5})-(?P<workspaceID>[a-z0-9][0-9a-z\-]+).ws(?P<location>-[a-z0-9]+)?.{$GITPOD_DOMAIN} | |||
handle @workspace_port { | |||
reverse_proxy ws-{re.host.workspaceID}-ports.{$KUBE_NAMESPACE}.{$KUBE_DOMAIN}:{re.host.workspacePort} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you removing the mapping for workspace ports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ws-proxy does it after adjusting headers: https://github.com/gitpod-io/gitpod/pull/4419/files#diff-39f2e37e657f269523bb53adff2f549f05b1af3db45432b89daa1c2068847ef3R269
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as i understood without this change it does not go through ws-proxy at least in prev env?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
Just in case, I copied this configuration from what we had in NGINX previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in nginx we also delegated to ws-proxy:
gitpod/chart/config/proxy/vhost.server.conf
Lines 160 to 192 in a0a5017
server { | |
listen {{ $listen }}; | |
# Matches: | |
# - (webview-|browser-|extensions-)?+ for now, we only support Theia webviews here! (TODO is there a - meaningful - way to generalize this?) | |
# - (?<port>[0-9]{2,5})- port to forward to | |
# - (?<wsid>[a-z][0-9a-z\-]+) workspace Id | |
# - \.ws(-[a-z0-9]+)? workspace base domain | |
# "" needed because of {} (nginx syntax wart) | |
server_name "~^(webview-|browser-|extensions-)?+(?<port>[0-9]{2,5})-(?<wsid>[a-z0-9][0-9a-z\-]+)\.ws-{{ .Values.components.proxy.withWsCluster.shortname }}\.${PROXY_DOMAIN_REGEX}$"; | |
{{- if $useHttps }} | |
include lib.ssl.conf; | |
include lib.https_redirect.conf; | |
{{- end }} | |
# include lib.workspace-port-locations.conf; | |
include lib.region-headers.conf; | |
include lib.resolver.conf; | |
location / { | |
include lib.proxy.conf; | |
include lib.ws-sse.conf; | |
# Increase connect timeout | |
proxy_connect_timeout 10s; | |
# Set max body size to make big uploads work | |
client_max_body_size 2048m; | |
# disable the error log to not spam our logs when the kube DNS doesn't know about the service yet | |
error_log off; | |
proxy_pass http://ws-proxy.{{ .Values.components.proxy.withWsCluster.namespace }}.svc.cluster.local:8080$request_uri; |
e001a06
to
6370ef8
Compare
/werft run 👍 started the job as gitpod-build-ak-fix-web-sockets.5 |
@akosyakov this change LGTM but can you split the change in two different PRs? |
Do you mean commits? I’m offline till tomorrow morning if it is critical and should go in tomorrow deployment. Feel free to split, rebase and merge yourself. |
No, two PRs. The caddy change has no relation with the one in ws-proxy. Just to not assume in the future that are related in any way. |
Aren't those changes related, i.e. would the fix work without the caddy change? |
Yes. The change to Caddy is for core-dev to behave similarly to production (all traffic through ws-proxy) |
Those two changes are separate indeed. One is to bring core-dev closer to ws-proxy, the other is fixing ws-proxy itself. All that said, I'd propose we merge those changes because they make a whole lot of sense :) |
Thanks for the clarification, Alejandro. So I guess my confusion is good proof of your concern. That said, I agree we should merge it as is to be able to get it in front of users ASAP. |
It's for core-dev to behave similarly to production.
6370ef8
to
5d92f84
Compare
I split into 2 commits with detailed explanation from this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
a work-around for servers which does not respect case-insensitive headers, see #4047 (comment)
5d92f84
to
de8cb0a
Compare
What it does
How to test