Nginx as proxy server for Apache

I would like to use Nginx as proxy server for Apache. Out of the box Virtualmin could not deal with this. But I would like to do a few modifications in order to make this working.

Nginx will listen on IP_ADDRESS:80
Apache will listen on IP_ADDRESS:8080

Some people recommend Apache listening on localhost, but I had trouble setting this in Virtualmin, so I prefer to keep the IP_ADDRESS instead of localhost. I will find a way to block incoming requests on port 8080 but allow incoming requests from nginx on port 8080.

Well, I found a way to set this up inside Default Settings -> Apache website. I will set up

Port number for virtual hosts: 8080
Port number for SSL virtual hosts: 8443

External port number for virtual hosts: Port 80
External port number for SS virtual hosts: Port 443

Could this work?

Another solution is changing the ports after a Virtual Server is created. Could this work too?

I can do this manually but I discovered that once I change the files manually Virtualmin is giving errors.

  1. I need a solution from inside of Virtualmin to set up Apache behind Nginx

  2. I someone could help me with IPTables to drop 8080 from outside but accept it if coming from Nginx.

Thank you.