I am looking for a way to create a Virtual Host (no real physical path) that just redirects a domain (preferably, I can configure Let’s Encrypt on said domain through Webmin/Virtualmin’s GUI), say app1.domain.com, to an app locally hosted on a port, say, localhost:9999. Usually, I would do this with Nginx Proxy, but since it was suggested to me that I didn’t have to use both Nginx and Apache at the same time, I am wondering if there is any tutorial that can help me do this.
Apache is a full-featured proxy. And, of course, nginx is a full-featured web server…the two servers are effectively interchangeable for most users. It was not suggested you shouldn’t use nginx if that’s what you’re familiar with…it was that it makes no sense for most people to run both Apache and nginx on the same system. They can both do anything you need to do.
So, you do it the same way you do it in nginx: Proxy to it. The basic examples in the Apache docs cover most common use cases: mod_proxy - Apache HTTP Server Version 2.4
It’s usually only a handful of lines in the config file, mostly just a ProxyPass and ProxyPassReverse line for each app, and making sure mod_proxy is being loaded.
For PHP apps, you don’t need to do anything. Virtualmin handles setting up all the configuration for proxying with PHP-FPM (or one of the other, less good, execution modes), and you just dump your PHP files in public_html.
We have a UI for adding the proxy rules, but I think it’s only in Virtualmin Pro (probably should trickle down to GPL by now), but it’s so simple to add them, I think most folks can do it.
As an aside, if you’re more familiar/comfortable with nginx, you may prefer to install Virtualmin using the --bundle LEMP mode of the installer (you’d need to start over with a fresh system, there is no easy way to switch between Apache and nginx). There are a few features nginx doesn’t have that Apache has or that don’t have GUI support in Virtualmin/Webmin, but most users never run into it, and Virtualmin now papers over the biggest of them (stuff like CGI scripts can be run with fcgiwrap, and Virtualmin sets that up automatically).