Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Extensions fail to load when using reverse proxy with subpath. #7006

Closed Answered by code-asher
davidliyutong asked this question in Q&A
Discussion options

Hello everyone,

I am deploying a code-server instance with Nginx as a reverse proxy. The two are bundled in one docker container. The plan is to serve code-server under /coder/ subpath, and other services under their unique paths. The editor works fine. I can access the interactive terminal, open every panel, and install extensions from the marketplace. It is just that the extensions are not working.

Here are the details: The code-server and nginx reside in the same container. The code-server is launched with code-server --bind-addr 0.0.0.0:3000 --auth none --cert false and listens at port 3000. The nginx daemon listens at port 80. Its configuration
looks like:

location ~ ^/coder/(.*)$ {
 proxy_pass http://127.0.0.1:3000/1ドル;
 proxy_http_version 1.1;
 proxy_set_header Upgrade $http_upgrade;
 proxy_set_header Connection "Upgrade";
 proxy_read_timeout 300;
 proxy_set_header Host $http_host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
 add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
 client_max_body_size 0;
 }

The docker container is launched with docker run --rm -p 3000:3000 -p 8000:80 coderwithnginx:latest, exposing both port 3000 and port 80. When accessing via http://127.0.0.1:3000, the extensions work. However when accessing via http://127.0.0.1:8000/coder/, only the editor and terminal work. It looks like the extensions are installed but not activated, and I am getting error messages in the dev console.

Screenshot for the working scenario

截屏2024年09月20日 13 10 04 > Screenshot for the failed scenario 截屏2024年09月20日 13 10 37

What could be the possible causes?

You must be logged in to vote

Do the query parameters get included in the location match? Wonder if you need proxy_pass http://127.0.0.1:3000/1ドル$is_args$args;.

Or this should also work, I think:

location /coder/ {
 proxy_pass http://127.0.0.1:3000/;
}

Replies: 1 comment 1 reply

Comment options

Do the query parameters get included in the location match? Wonder if you need proxy_pass http://127.0.0.1:3000/1ドル$is_args$args;.

Or this should also work, I think:

location /coder/ {
 proxy_pass http://127.0.0.1:3000/;
}
You must be logged in to vote
1 reply
Comment options

Do the query parameters get included in the location match? Wonder if you need proxy_pass http://127.0.0.1:3000/1ドル$is_args$args;.

This solution works! Thank you very much!

Answer selected by davidliyutong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /