question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Port forwarding feature via subdomain/path

See original GitHub issue

Is it possible to provide port forwarding feature that native VS Code provides?

The Coder web version of VS Code also provides this here: https://coder.com/docs/code-server/latest/guide#accessing-web-services-1

The above linked service does it by proxying all requests to <port>.somesubdomain.com to the application running on that port in the container. Another way it provides is <url_to_access_vscode_online>/proxy/<port>.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
aptalcacommented, Nov 30, 2021

fyi, we implemented that feature via an nginx trick in our SWAG reverse proxy. We simply use a named group in the server_name regex to capture the port as a var, and use that var in the proxy_pass directive: https://github.com/linuxserver/reverse-proxy-confs/blob/master/openvscode-server.subdomain.conf.sample#L74

0reactions
TiemenSchcommented, Nov 29, 2022

I think there are a couple of possible duplicate issues: #320 and to some extent #163

The mentioned workaround by @aptalca works using an additional prefix rather than a subpath. Could we get it to work with a subpath, too?

Something along the lines of:

server {
    listen 8888;
    listen [::]:8888;

    server_name example.com;

    location /code/ {
        proxy_set_header    X-Real-IP  $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    Host $http_host;
        proxy_redirect      off;
        rewrite             ^/code/(.*) /$1 break;
        proxy_pass          http://127.0.0.1:3000;
    }

    location /code {
        return 301 /code/;
    }
}

where we should get it running on example.com:8888/code. That doesn’t work though, but I’ve got no clue if this is at all possible with only an NGINX configuration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to redirect (sub)domain to a certain IP address along with ...
Yes, it is possible to redirect your subdomain to the IP address along with a port in the same way. However, if you...
Read more >
Is there a way to forward a port based on subdomain? [duplicate]
First up, there's no explicit requirement in your question that all of those names resolve to the same IP address -- so, you...
Read more >
Redirect Subdomains allowing all port traffic to flow without ...
I have several sites I want to be able direct the subdomain to an internal IP. I created map settings in "system /...
Read more >
How do I route a subdomain to an application running on my ...
Create a DNAT rule on the router, forwarding TCP\80 to 192.168.0.13:9177. easy peasy. if you want people to be able to hit it...
Read more >
How can I Forward a subDomain to a specific port?
It can't be done by anything. When the remote computer opens a TCP connection, all it tells you is the IP address and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found