Can't resolve localhost when not on home network - linux

I'm trying to run my node app on localhost. After starting it reports that the app is running on localhost:8080. When I am on my home network I'm allowed to access my app on https://localhost:8080. When I am connected to work VPN or work wifi, my /etc/resolv.conf is generated differently and I'm no longer allowed to access my app on the localhost URL. I am able to access the app by giving the direct IP (which will not be 127.0.0.1 when I am on work network/VPN).
Please help me set my network configuration so that I can always access my app on https://localhost:8080
(Note that I am dependant on allowing automatic changes of my /etc/resolv.conf file to be able to access domains only exposed through the work nameserver.)

Related

Change NodeJS local server access URL

Is it possible to change the URL used to access my local NodeJS server?
For instance, I have a Node server running on port 3000, so I can access this server directly through:
http://localhost:3000/
And other users on my network can access it through:
http://[MY_IP_ADDRESS]:3000/
Is it possible to forward this server to a local URL, like http://example/
I know that, in order to remove the port from the URL I need to bind the app on port 80, but I can't find anything about changing de URL.
Not very clear what you want, to be honest and your set-up. You use local computer or server in local network?
If you want URL in your local network isolated - that's not possible hence the URL protocol forwards requests from domain name to certain ip address.
If you want only internal access in your local network you only need to know your local ip address and make sure your firewall allows local connections. Depending on your OS run ip check in cli and voila - that's your ip.
If you want external connections then you need to have a static ip address which you should obtain from your internet provider and afterwards you need to alter you router settings and set up port-forwarding to your local machine. It will then listen to external connections on certain port and forward it to your local machine where nodejs listens (itself or through web-server). Here you can redirect your domain URL name via A-record to your static ip address of your router and port-forward to local machine.
Check out this guide for most routers for external port-forwarding.
UPD: checkout this answer

Can't connect to localhost on my application server but can access it via web

I have a website which is accessible via its URL but strangely i cannot connect to it via localhost on the server itself.
I have ensured that "127.0.0.1 localhost" is in my hosts file
I have checked that no other application is using port 80
I've ticked "Bypass Proxy Server for local addresses"
Pinging my local host from command line returns data When you go to the domain host URL the application loads successfully
Good news is my site is fully functioning but i just cannot figure out how to connect to it on localhost in my browser! any ideas?
Added details as requested;
Its a website not app if that was misleading.
The webserver is IIS on an Amazon EC2 windows instance.
The root URL is just a simple html page, which i can access via the domain URL.
However when i RDP onto the Server itself and try to access the localhost, it continually blocks me, the page wont load.
It is possible that your application is only listening on external IP address. To bind your application on all IP address, you may make your application listen on 0.0.0.0.
And could you please show the related code to help locating the problem?

What IIS or network config is necessary to be able to use a network alias from the host server?

Our web server hosts some APIs that other apps running on the same server need to call. These calls are failing with a 401.1 error.
The server has a single IP address. The server name and the network alias we use both ping to this same address.
I can browse to addresses on the server from other computers using either the machine name or the alias.
If I connect to the server I can't browse to any addresses using the alias. The machine name works locally but not the alias.
If I use the alias I am prompted to to login with my credentials. These are not accepted and then leads to 401.1 error.
How can I configure the server and/or IIS to allow the network alias to be browsed from the same server that the alias links to?

Invalid Host header when trying to connect reactjs and domain name

I'm trying to deploy a JS app (back in nodejs, front in reactjs) on a hosting server. I've dockerized everything (back, front and database) and everything works well, I can access my app through the IP address of the server.
Now I'm trying to setup a domain name to point to my app.
I've a Invalid Host header when I try to access from domain name (while still working accessing through server's IP address).
I've tried to add a HOST:mydomain.com to the .env of my reactjs app but I got this error Could not find an open port at mydomain.com
Would love if someone can help me through this :)
Given app works by IP, you can leave config of app as is. Do not add HOST or any other config.
IP to name mapping is done using DNS. So made DNS registration in DNS zone like this
mydomain.com A <IP address of app>
Where A is DNS entry type. Or made request to provider to register A entry type for you.
For testing purposes you may do mapping on any Windows PS using hosts file C:\Windows\System32\drivers\etc\hosts where mapping is done by
<IP address of app> mydomain.com
hosts works on one PC only.
After adding to hosts or to DNS try ping mydomain.com to make sure that name is resolved to correct IP address.
Mapping on web server is done when one web server hosts several different sites on one IP. But when you use Docker it's best to have one Docker container for one service.

How to access localhost:3000 on AWS through NodeJS server

I have a node js server set up on AWS using Linux instance(Ubuntu 14.04) I have started the server using the command npm start How do I access the localhost:3000. And when I do it locally I am able to access all the webpages by going to the browser. How can i access it when the server is on cloud?
The localhost host name is resolved to IP address 127.0.0.1 (or IPv6 equivalent) which is routed to the loopback interface so that you cannot reach any other host than your own with that. That's why it's called localhost in the first place.
To reach your host from the outside you need to know its external IP address or a domain name that resolves to its external address. You should be able to see your external IP in the dashboard. If you can't then see this answer.

Resources