Using subfolder proxy with openvscode-server

Currently I am trying to use SWAG to reverse-proxy my openvscode-server instance. From the swag container I am able to ping the openvscode-server container but when I try the request http://mydomain.com/openvscode-server I only see “Not found”.
Is it possible to reverse-proxy with a subfolder for openvscode or is it only possible with a subdomain.

Here my openvscode-server.subfolder.conf file

location /openvscode-server {
    return 301 $scheme://$host/openvscode-server/;
}

location ^~ /openvscode-server/ {
    # enable the next two lines for http auth
    auth_basic "Restricted";
    auth_basic_user_file /config/nginx/.htpasswd;

    # enable for ldap auth (requires ldap-server.conf in the server block)
    #include /config/nginx/ldap-location.conf;

    # enable for Authelia (requires authelia-server.conf in the server block)
    #include /config/nginx/authelia-location.conf;

    # enable for Authentik (requires authentik-server.conf in the server block)
    #include /config/nginx/authentik-location.conf;

    include /config/nginx/proxy.conf;
    include /config/nginx/resolver.conf;
    set $upstream_app openvscode-server;
    set $upstream_port 3000;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;
}

Generally if an app only has subdomain conf’s, usually means means won’t work. Some apps just don’t like it.

I’m setting this up as well but I’m using Caddy. I have it working up to a point but the issue isn’t that it’s being served through a subpath in the reverse proxy. The issue is the Content-Security-Policy for openvscode server on the extension worker. But to get you unstuck and at least getting it to where I’m at you’ll need to add the --server_base_path <your subpath> to openvscode-server on startup. That will root it to the the subpath you specified in your reverse proxy configuration. For example if you have:

https://my-proxy.domain.com/openvscode-server

you would have –server-base-path openvscode-server set at startup. I just looked at how the ENTRYPOINT is configured for this image and it’s run using the init system. I generally haven’t done this but you can look at

root/etc/s6-overlay/s6-rc.d/svc-openvscode-server/run

in the source directory at github. I rolled my own image so I didn’t run into this. For the linuxserver image you can launch it like this as an example:

podman run -e 'CODE_ARGS=--server-base-path foobar' -d linuxserver/openvscode-server:latest

If you look at the logs you’ll see:

[migrations] started
[migrations] no migrations found
usermod: no changes
───────────────────────────────────────

  ██╗     ███████╗██╗ ██████╗
  ██║     ██╔════╝██║██╔═══██╗
  ██║     ███████╗██║██║   ██║
  ██║     ╚════██║██║██║   ██║
  ███████╗███████║██║╚██████╔╝
  ╚══════╝╚══════╝╚═╝ ╚═════╝

Brought to you by linuxserver.io
───────────────────────────────────────

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID: 911
User GID: 911
───────────────────────────────────────
Linuxserver.io version: 1.96.0-ls153
Build-date: 2024-12-21T06:52:38+00:00
───────────────────────────────────────

setting permissions::config
setting permissions::app
[custom-init] No custom files found, skipping…
**** No connection token is set ****
Server bound to 0.0.0.0:3000 (IPv4)
Extension host agent listening on 3000

[02:19:19]

Web UI available at http://localhost:3000/foobar
[02:19:19] Extension host agent started.
[02:19:19] Started initializing default profile extensions in extensions installation folder. file:///config/.openvscode-server/extensions
[02:19:19] Completed initializing default profile extensions in extensions installation folder. file:///config/.openvscode-server/extensions
Connection to 127.0.0.1 3000 port [tcp/*] succeeded!
[ls.io-init] done.

Notice the Web UI available at http://localhost:3000/foobar.