Allow Apache and Nginx website together

Very popular configuration is nginx as reverse proxy for apache for dynamic queries, and direct access for static content. At now Virtualmin don't allow to enable both - Apache and Nginx website with error:

Failed to modify server : Nginx cannot be enabled for a domain that also has an Apache website

This can be disabled via commenting /usr/share/webmin/virtualmin-nginx/virtual_feature.pl file - line 66:

return $text{'feat_eapache'} if ($d->{'web'});

to

# return $text{'feat_eapache'} if ($d->{'web'});

Instead of this hack - will be good to have an option in Virtualmin configuration "Allow Nginx website together with - Apache website" - can you add it?

Status: 
Active

Comments

Howdy -- we had received some requests for doing something similar with Varnish some time ago.

And while the configuration itself was a bit complicated to add into Virtualmin as a built-in feature, what we did is write up instructions on how to manually configure that.

However, Varnish has some disadvantages that are significant -- notably the idea that it doesn't do SSL... which is a big deal now that SSL is becoming more and more prevalent.

Out of curiosity, what kind of configuration are you doing to get things working after you enable both Apache and Nginx?

For solve this problem we must have separate web ip:port settings for Nginx virtualserver and Apache, compare it and and shows this error only when Apache & Nginx ip:port are equal.

While I can understand why this setup is useful, it would take some work to properly support in Virtualmin as there are strong assumptions in the code that only one webserver is active (and needs to be configured) at a time.

At now this configuration works well on my 2 webservers when I change one line in Virtualmin script. The problem is that nginx & apache need 2 different port, but I configure post-save script that replace port for Nginx to needed.

This configuration with both apache+nginx on one server - is very popular, you can see many manuals by googling "nginx apache proxy", so Nginx give directly static content (files) and proxies dynamic content to apache backend.

For add ability to configure this in virtualmin without hacking - we need only 2 things: - Separate Nginx ip:port settings from Apache - Enable together Nginx & Apache on one virtualserver.

Out of interest, which content do you use Nginx to serve, and which do you use Apache for? Or is Nginx doing pure caching only?

I have 100+ websites on server, and only 5 of them give 80% of load for my server. So by default nginx works like global proxy for all sites to apache (redirects all queries from external-ip:80 to localhost:8080 apache port): https://devops.profitbricks.com/tutorials/configure-nginx-as-a-reverse-p...

But this 5 high-load sites I configure to work directly via nginx+php-fpm, without apache, for increase performance and decrease server load.

Even when nginx works as reverse proxy to apache - there are already good memory usage improvements, because apache process will give content to nginx and shut down with free-up memory, and nginx will give this content to user longer time with less memory usage.

I am interested in implementation of similar request, but not limiting only to Nginx, but any other proxy like, for example, Pound or HAProxy, which could be used just for SSL termination (leaving all the web-server functionality to Apache intact). Discussing this on https://www.virtualmin.com/node/53661