Zend certified PHP/Magento developer

Using apache2 to access multiple different internal servers using one public ip

I am a novice/hobbyist at server/networking stuff, so forgive me if I miss something obvious

My primary goal is to configure apache2 so that I can access multiple different self hosted servers under 1 residential ip address, without needing to use different ports for each server [eg. accessing Nextcloud, Matrix Element, and maybe a DAppNode for Ethereum if I can get that to work]. I can only forward a port to one ip each, so I figure, if I forward port 80 to an apache server that then redirects traffic based on domain name, I can access each site under one public ip.

So I got to testing this idea using a free tier of Amazon’s EC2 service. I set up one apache server, and one Matrix server [which runs under a docker container]. I saw what “ProxyPass” was supposed to do, so figured that was my solution. This is my config to redirect traffic to the Matrix container

<VirtualHost *:80>
        ServerName test1.example.com
        ProxyPreserveHost On
        ProxyPass / http://172.18.0.3:80
        ProxyPassReverse / http://172.18.0.3:80
</VirtualHost>

And yet going to test1.example.com [not actual url] gives me a “service unavailable” error, but the page loads fine while going to matrix.example.com [which is directed at the matrix server’s public ip]. I’m probably doing something wrong, but I’m not sure what, or how to do it right

Also, I figured that I’d be able to have apache distinguish between the different subdomains if I put different subdomains as the server names, but I have no idea how that’s how it works