Skip to content

[Bug]: Nginx dramatic port proxying :302 not found #5119

Description

@damonwan1

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: Chrome
  • Local OS: win10
  • Remote OS: Centos 7.6
  • Remote Architecture: ARM
  • code-server --version: 4.3.0

Steps to Reproduce

My requirement is to achieve dramatic port proxy with nginx and code-server.

For Example,there is a situation.

  1. one user access our website and click "create my vscode"button, it will run code-server by "code-server --auth none --host 0.0.0.0 --port 20000", so remote server A has started a code-server service on port 20000. (Different user has different port number20001,20002,etc.)
  2. User access the code-server website by url "http://mywebsite.com/vscode/20000/"
  3. The remote application server B has deployed nginx, the user request will firstly target serverB and the nginx on serverB proxy the request to server A(code-server). sry, it is a simply process.
  4. The nginx conf is below. I have tried all the method of conf, but it didn't work.
                location ~* /vscode/([0-9]+)/
                {
                         proxy_pass  http://137.2.2.1:$1/;
                         proxy_set_header X-Real-IP $remote_addr;
                         proxy_set_header Host $host;
                         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                         proxy_http_version 1.1;
                         proxy_set_header Upgrade $http_upgrade;
                         proxy_set_header Connection "upgrade";
                         proxy_redirect off;
                }

It didn't work ,too.

              location ^~/vscode/20000/
                {
                         set $ter 20000
                         proxy_pass  http://137.2.2.1:$ter/;
                         proxy_http_version 1.1;
                         proxy_set_header Upgrade $http_upgrade;
                         proxy_set_header Connection "Upgrade";
                }

However, the non-dramatic params work well.

           location ^~/vscode/20000/
                {
                         proxy_pass  http://122.10.10.112:20000/;
                         proxy_http_version 1.1;
                         proxy_set_header Upgrade $http_upgrade;
                         proxy_set_header Connection "Upgrade";
                }

Expected

Actually, i really need a dramatic port proxy, by http://mywebsite.com/vscode/20001/, http://mywebsite.com/vscode/20002/,http://mywebsite.com/vscode/20003/ automaticly.###

Actual

The wrong proxying process throws 302 not found.

I checked it by chrome F12, it could find a lot of 302 redirect request. by the way, i have flush my coockies.

Logs

No response

Screenshot/Video

image

Does this issue happen in VS Code?

  • I cannot reproduce this in VS Code.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

Thanks a lot for solving this problem. we have tried so many ways and viewed a lot of issues, googles...

Activity

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

    bugSomething isn't workingtriageThis issue needs to be triaged by a maintainer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions