Score:0

Why is the Nginx server unreachable despite the ports being open?

jp flag

I am in a very unusual situation and I have spent almost 8 hours trying to figure out what the problem is.

The setup

I have a server running Debian 11. Inside this server, I have a setup a CentOS virtual machine with KVM. The virtual machine hosts a complex web application behind an Apache server. The network interface of the KVM is NAT and therefore to access the web application, I have setup port forwarding rules using libvirt hooks as described here:

https://wiki.libvirt.org/page/Networking#Forwarding_Incoming_Connections

My setup forwards any incoming connections to port 443 to the Apache server on the Virtual Machine and this is working fine.

I have also set up an Nginx server on the host machine as I intend to use it as a reverse proxy. I will be hosting another application on the host server on port 9000. Using the Nginx for reverse proxy, I plan to redirect redirect all requests to https://example.com to the Virtual Machine and all requests to https://example.com/app/ to the web application running on port 9000.

The problem

I installed the Nginx server after setting up the Virtual Machine and its corresponding Port forwarding rules. But when I try to run the Nginx server's start page, it is not reachable. I understand that port 443 gets forwarded to the VM. So, I try to load with http://example.com expecting it to load the Nginx start page on port 80. But it keeps telling that the website is unreachable.

What I have tried so far?

I suspected that the port forwarding rules from the host to the guest might be the root cause here. So I changed the port forward rule from port 443 to 8000. So any requests to port 8000 would be forwarded to the Apache server on the VM. But after doing this, port 443 became unreachable as well.

I tried to completely clear the iptables as described here:

Clear and reset iptables in Debian

But still, the Nginx server remains unreachable.

Also, very strangely, after clearing the iptables, when I try to access the application running on port 9000 with http://example.com:9000 I get a 400 Bad request error and when I change the protocol to https, the page becomes unreachable.

Any advice would be very helpful. Thank you.

djdomi avatar
za flag
Questions seeking installation, configuration or diagnostic help must include the desired end state, the specific problem or error, sufficient information about the configuration and environment to reproduce it, and attempted solutions. Questions without a clear problem statement are not useful to other readers and are unlikely to get good answers.
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.