Skip to content

Allow running behind proxy#237411

Merged
aeschli merged 7 commits intomainfrom
aeschli/210455-2
Jan 7, 2025
Merged

Allow running behind proxy#237411
aeschli merged 7 commits intomainfrom
aeschli/210455-2

Conversation

@aeschli
Copy link
Contributor

@aeschli aeschli commented Jan 7, 2025

Continuation from #210455

Thanks to @mering for the original work.

See #210399 for the motivation.

Commits:

  • Serve from / and basePath
  • Honor X-Forwarded-Prefix header
  • Honor X-Forwarded-Port header

Test procedure:

  • Compile via npm run compile
  • Run scripts/code-server.sh
  • Run an nginx proxy with the following config:
http {
    server {
        listen 8080;
        listen [::]:8080;

        location /some/path/ {
            proxy_pass http://localhost:9888/;
            proxy_http_version 1.1;
            proxy_set_header Host $host;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $http_connection;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_set_header X-Forwarded-Prefix "/some/path";
        }
    }
}

events {
}

Fixes #210399, #225706

@aeschli aeschli self-assigned this Jan 7, 2025
@aeschli aeschli enabled auto-merge (squash) January 7, 2025 15:59
@vs-code-engineering vs-code-engineering bot added this to the January 2025 milestone Jan 7, 2025
jrieken
jrieken previously approved these changes Jan 7, 2025
@aeschli
Copy link
Contributor Author

aeschli commented Jan 7, 2025

Added on top of #210455:

  • splitted variable _serverRootPath to _serverBasePath and _serverProductPath
  • when forwarding a request to the web server use pathname without base and product name, but make sure the location is using the full url
  • add logging

@aeschli aeschli merged commit 972686c into main Jan 7, 2025
@aeschli aeschli deleted the aeschli/210455-2 branch January 7, 2025 16:48
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Feb 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow web server behind proxy

4 participants