Skip to content

Add --base-path flag for use with absolute proxy #6770

Closed

Description

@code-asher

This is not for code-server itself (since it works relatively), it would just be prepended to absproxy requests for applications that need the full path.

Activity

  1. rafaelnferreira commented on Aug 25, 2024

    @rafaelnferreira
    Contributor

    Hi @code-asher I've submitted a PR to resolve this case, could you have a look when you have a chance? Thanks

  2. yuzhuoheng commented on Oct 14, 2024

    @yuzhuoheng

    abs-proxy-base-path It didn't work. This is my startup command:
    企业微信截图_17288752683468
    I tried to open it with a browser, and the page prompt was as follows:
    企业微信截图_1728875413984

  3. code-asher commented on Oct 15, 2024

    @code-asher
    MemberAuthor

    I answered in the other issue, but as mentioned above

    This is not for code-server itself (since it works relatively), it would just be prepended to absproxy requests for applications that need the full path.

  4. code-asher commented on Oct 15, 2024

    @code-asher
    MemberAuthor

    In other words, if you have an application on port 3000 and it requires absolute paths, and you have a reverse proxy serving code-server at /some/path, you can set --abs-proxy-base-path=/some/path, and then you can access your app with http://code-server.com/some/path/absproxy/3000.

    Hope that helps!

  5. kimboslice99 commented on Feb 5, 2025

    @kimboslice99

    I think the long list of people that keep asking various questions on getting code-server to work under a base path should be a strong enough indicator that the docs are not thorough enough.

  6. code-asher commented on Feb 18, 2025

    @code-asher
    MemberAuthor

    Fair. I believe it is confusing because there are potentially two proxies: the one that hosts code-server, and code-server's built-in proxy, for viewing webapps you are working on.

    The base path flag is for code-server's built-in proxy. Nothing needs to be done to make code-server itself work behind another proxy, like Caddy or NGINX or so on.

    We are open to PRs that clarify the docs. I think I may be too close to the source code to understand how to word them in a way that makes sense to other folks.

  7. kuun993 commented on Aug 6, 2025

    @kuun993

    In other words, if you have an application on port 3000 and it requires absolute paths, and you have a reverse proxy serving code-server at /some/path, you can set --abs-proxy-base-path=/some/path, and then you can access your app with http://code-server.com/some/path/absproxy/3000.

    Hope that helps!

    This doesn't seem to work...

    Image
  8. code-asher commented on Aug 7, 2025

    @code-asher
    MemberAuthor

    By "doesn't seem to work" do you mean you get a blank page or 404 when you go to <domain>/usr/123/workspace?

    code-server always listens at the root, you need a reverse proxy (NGINX, Caddy, etc) to rewrite the path to make code-server load at <domain>/usr/123/workspace.

    The only thing --abs-proxy-base-path does is when you go to <domain>/usr/123/workspace/absproxy/<port>/<path> it will proxy to http://0.0.0.0:<port>/usr/123/workspace/<path> instead of http://0.0.0.0:<port>/<path>. It is a workaround for proxying applications you are developing that need to know the full path rather than working relatively, and has no effect on code-server itself.

  9. kuun993 commented on Aug 10, 2025

    @kuun993

    By "doesn't seem to work" do you mean you get a blank page or 404 when you go to <domain>/usr/123/workspace?

    code-server always listens at the root, you need a reverse proxy (NGINX, Caddy, etc) to rewrite the path to make code-server load at <domain>/usr/123/workspace.

    The only thing --abs-proxy-base-path does is when you go to <domain>/usr/123/workspace/absproxy/<port>/<path> it will proxy to http://0.0.0.0:<port>/usr/123/workspace/<path> instead of http://0.0.0.0:<port>/<path>. It is a workaround for proxying applications you are developing that need to know the full path rather than working relatively, and has no effect on code-server itself.

    yes, i get a 404 page when i go to /usr/123/workspace


    For example:

    command: code-server --auth none --bind-addr 0.0.0.0:8080 --abs-proxy-base-path /context-path

    expect: get a normal page when i go to localhost:8080/context-path
    actual: i get a 404 page when i go to localhost:8080/context-path

    What should I do?

  10. code-asher commented on Aug 11, 2025

    @code-asher
    MemberAuthor

    You will need to use a reverse proxy like Caddy or NGINX to serve code-server on a subpath. For example with NGINX you can use https://github.com/coder/code-server/blob/main/docs/guide.md#using-lets-encrypt-with-nginx but change location / to location /context-path/ (for convenience you may want to also add a redirect from /context-path to /context-path/; the trailing slash is important so the relative requests resolve properly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSome improvement that isn't a feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions