Score:0

How to forward my localhost to my VPS's ip address?

cn flag

I am running a localhost service on my VPS.

When i start the service, this is what i get:

Navigate to https://127.0.0.1:7443 in a browser

The problem with this is that i can't open it in my browser because it's a VPS.

I have tried running ngrok, but it says connection to localhost failed.

Is there a way i can forward it to the IP address of the same VPS the localhost is running? For example i open the browser and i enter my servers IP?

cn flag
Can you clarify what you mean by a "localhost" service? The message you see indicates that the service is not bound to an external interface, you'll need to update it's config somehow.
Score:0
sa flag
bav

It is possible to arrange this through a proxy. I have a WireGuard that has the internal IP address of the participants. Let's take an example from a server that connected VPN with IP address: 10.8.0.2 (internal IP address) VPN IP address: 10.8.0.2

You need to install on your vps a vpn which creates a local network. I have wireguard. Then set nginx as proxy. once installed, open a browser and enter the IP address of your vps. If the nginx greeting opens. This is good. It should work something like this: a request comes to vps, nginx processes it and sends information to the connected server via vpn (WireGuard), waits for a response and sends it back to who sent the request.

It remains to fix the config.

vpn nginx config enter code here

 server {
    client_body_timeout 5s;
    client_header_timeout 5s;
    listen       80; #port
    server_name  2.16.136.1;# domen/ip vpn

    add_header Access-Control-Allow-Origin *;
    location / {
              #limit_conn addr 3;
               limit_rate 71680k;
                 #if ($http_cookie ~* ".+" ) {
                #set $cookie_cache_bypass 1;
                #}
                proxy_pass http://10.8.0.2:5000;
                
                proxy_read_timeout      300;
                proxy_connect_timeout   300;
                proxy_redirect          off;
                proxy_set_header        X-Forwarded-Proto https;
                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-Ssl   on;
                proxy_set_header        X-Frame-Options   SAMEORIGIN;
                
                proxy_cache all;
                proxy_cache_valid 404 502 503 20m;
                proxy_cache_valid any 2h;
                proxy_cache_use_stale error timeout invalid_header updating;
    
    
    
                gzip on;
                gzip_disable "msie6";
    
                gzip_vary on;
                #gzip_proxied any;
                gzip_comp_level 5;
                gzip_min_length 2240;
                gzip_proxied expired no-cache no-store private auth;
                gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
                
            }
}

PS: sorry for config typos if there are any.

Score:0
cn flag

Start the web server listening on remote addresses, and access over the internet.

Read the documentation of the web server in question for how to do that. Prefer production deployment scenarios, with a known web server. Possibly insert a load balancer or other utility proxy in the middle.

Toy servers for development purposes are not hardened or performant enough for operational use. And might listen on loopback addresses only.

Get a domain name for this thing as well. Easier to issue TLS certs for a name, and also easier for humans to remember.

Score:0
th flag

Do you already tried to access the port with the IP of the VPS rather than using localhost, because some application said in the console go to localhost but listen on all interfaces.

An alternative if the service only listens on localhost and you have ssh access to the VPS you can port forward the localhost port of you VPS to your local machine.

ssh user@vpsIP -L 7443:localhost:7443

explanation of -L [LOCAL_IP:]LOCAL_PORT:DESTINATION:DESTINATION_PORT the first square brackets is optional if you want to specify where to listen on your machine, default is all interfaces

Score:-1
aq flag

you could install nginx proxy manager for example.

There you can add a domain or your public ip address and forward to https://127.0.0.1:7443 then you could access this host with your public ip address.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.