linuxserver / reverse-proxy-confs

These confs are pulled into our SWAG image: https://github.com/linuxserver/docker-swag
GNU General Public License v3.0
1.33k stars 300 forks source link

[BUG] swag auto proxy replacing all server_name entries on openvscode-server.subdomain.conf #619

Closed jesuzon closed 10 months ago

jesuzon commented 10 months ago

Is there an existing issue for this?

Current Behavior

When using the swag auto proxy mod with a label for a custom url (in my case, I have set swag_url to code.) the mod uses the template in the title correctly, but changes all the entries of server_name to whatever swag_url is (code.).

This would be fine for any other container, but in the case of openvscode-server, this leads to the loss of the clever way to capture ports as subdomains and expose them as per the template.

I have it working right now by modifying the conf created by the auto proxy mod and re-adding the regex string to capture the ports but with my desired url: "~^(?[0-9]{1,10}).code..*$";

I'm not sure if this is an issue with the auto proxy mod or if something can be done on the template side to fix this behavior

Expected Behavior

Ideally, the conf created by the auto proxy mod has 3 server blocks - 1 with the base url as set by swag_url, and the next 2 containing regex strings that have this swag_url within rather than the hard-coded .openvscode-server name

Steps To Reproduce

deploy docker container using the swag auto proxy mod and setting the swag_url to a custom value will lead to this issue.

Roxedus commented 10 months ago

Its a bug with neither, set your swag url to the regex-stanza https://github.com/linuxserver/docker-mods/issues/769

jesuzon commented 10 months ago

Its a bug with neither, set your swag url to the regex-stanza linuxserver/docker-mods#769

sorry for re-opening, but, the code-server and the openvscode-server templates aren't the same. In the openvscode-server there are 3 server blocks - one that handles the base url, and the other 2 to handle PORT as http and PORTs for https. All 3 are replaced by whatever swag_url is set to. Changing the swag_url to the regex string as suggested doesn't work as the 3 server blocks just conflict one another. It also would lead to an issue in differentiating http and https given one can only set swag_url once.

I think the reason for the 3 server blocks in the openvscode-server config is that openvscode-server doesn't have a proxy_domain configuration option like code-server does, but I'm not sure if this is really the case.

aptalca commented 10 months ago

That's correct. Openvscode-server conf has a very unique server block for proxying internal ports and differentiating between http and https (code-server internally does the first part but not the second).

That behavior is not compatible with auto-proxy at the moment and I was not able to come up with a quick fix. Any fix I could think of required too much effort and would add too many complications. Since it's the only conf with such an issue, I decided to leave it as is.

If you use auto proxy and set the server name, both the http and https proxy server blocks will have the same server name, which will break https proxy, but http proxy should still work as nginx should match the first one listed. Is that not the case?

jesuzon commented 10 months ago

That's correct. Openvscode-server conf has a very unique server block for proxying internal ports and differentiating between http and https (code-server internally does the first part but not the second).

That behavior is not compatible with auto-proxy at the moment and I was not able to come up with a quick fix. Any fix I could think of required too much effort and would add too many complications. Since it's the only conf with such an issue, I decided to leave it as is.

If you use auto proxy and set the server name, both the http and https proxy server blocks will have the same server name, which will break https proxy, but http proxy should still work as nginx should match the first one listed. Is that not the case?

Yeah, using auto proxy a setting the server name works for the base url, you just don't get the port functionality.

I think I'll move my setup to code-server as that seems to be working fine including ports