Test server app in VPS through localhost
I have nginx and ufw in my vps as well as a server app, which runs smoothly. I am having issues when I try to test the app by running localhost unit tests.
I wonder if the firewall ufw is blocking the responses? Or am I missing a configuration in my VPS? domain? How could I check this? When the test start they make request through the localhost, but never get a response. It gets hung up. Is it a problem if the VPS is a shared instance?
I need some expertise here. Thank you in advance!
4 Replies
✓ Best Answer
Yes, you should keep your /etc/hosts
file. Check out this guide on how to best configure it.
You can check your firewall's rules by running sudo ufw status
. With your app running you can also run the following commands to see if it's utilizing the port you have it configured for correctly:
ss -plntu
curl localhost:<port-number>
If those commands show that your application is functioning as it should on your desired port, you have a couple of options. First, you can configure Nginx as a Reverse Proxy to serve your application to the internet.
Alternatively, you can use port forwarding through an SSH tunnel to connect to localhost in your browser. You'd want connect to your development instance with the following command:
ssh -D 8080 user@<your.linode's.ip.address>
Then you can follow these instructions to configure Firefox to use Proxy. You can use other browsers, however, I've found Firefox to be the easiest.
Thanks! I found out what the root of the problem was. It turns out that the host file was someone gone and it did not recognize localhost
. There were not logs or anything. The app was just frozen after the first request. It was not clear if it was a nginx problem (it was already configured as a reversed proxy) or a ufw rule. Setting the ip address of localhost made it work. Your answer gives me further tools and things to consider next time.
I wonder if I erase the etc/hosts
file myself and forgot about it or if it came by default in the current share instance which I am experimenting with.