So for the last two days I have been struggling with setting up a Apache2 Reverse Proxy. Involved in this are 3 servers, all VMs, all on the same network. The proxy server is accessible from its public IP and subdomain name. ( Well say its PROXY.MYDOMAIN.COM<\/a>) and gave me the default ‘Apache2 is working’ page. The proxy server is the only server with a public face and ports 80 and 443 are forwarded to the proxy server. The proxy also has a SSL cert from letsencrypt by way of certbot and redirects 80 to 443.<\/p>\n
The two servers that are internal are a Wordpress site and a Nextcloud server, both are completely separate VMs.<\/p>\n
I have set the ports for Wordpress 80 = 8001, 443 = 8002 (SSL though it has no cert) and Nextcloud 80 = 8003, 443 = 8004 (It has a self signed cert.)<\/p>\n Wordpress was installed in /var/www/html/wordpress. I have set the /wordpress dir at the apache2 home dir so when you got to the servers IP 11.11.11.11:8001 there is no need to add …8001/wordpress<\/p>\n Nextcloud was installed in /var/www/html/nextcloud. Nextcloud I have not set the apache2 home dir to the nextcloud dir so you have to go to 22.22.22.22:8003/nextcloud to reach the site.<\/p>\n <VirtualHost *:80> ProxyRequests Off SSLEngine on<\/p>\n ServerName PROXY.MYDOMAIN.COM<\/a> SSLCertificateFile /etc/letsencrypt/live/PROXY.MYDOMAIN.COM/fullchain.pem Include /etc/letsencrypt/options-ssl-apache.conf So when I go to http://PROXY.MYDOMAIN.COM<\/a> I am redirected to https://PROXY.MYDOMAIN.COM<\/a> One question I still am not sure about, is it possible to use the same subdomain http://PROXY.MYDOMAIN.COM<\/a> with a reverse proxy so server the two sites? Like say the home ( http://PROXY.MYDOMAIN.COM<\/a> ) is the wordpress site and the nextcloud is http://PROXY.MYDOMAIN.COM<\/a> /nextcloud?<\/p>\n I have looked over various sites trying to figure out where I’m going wrong. I know someone will mention this so let me go ahead and answer. I have tried this with Nginx as well never could get it to work or even display anything. A lot of these ‘its so easy guides’ assume a little to much about the person that’s using them. Admittedly I have more experience with Apache2 but I’m still not the most learned when it comes to this type of project.<\/p>\n Thanks in advanced for any help or advice.<\/p>\n
<\/a>wordpress vhost<\/h5>\n
\nServerName PROXY.MYDOMAIN.COM<\/a>
\nRedirect / https:// PROXY.MYDOMAIN.COM/<\/a>
\nRewriteEngine on
\nRewriteCond %{SERVER_NAME} = PROXY.MYDOMAIN.COM<\/a>
\nRewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI}<\/a> [END,NE,R=permanent]
\n<\/p>\n<\/a>end of line<\/h5>\n
<\/a>wordpress ssl vhost<\/h5>\n\n\n
\nProxyPreserveHost On<\/p>\n
\nProxyPass / http://11.11.11.11:8001/<\/a>
\nProxyPassReverse / http://11.11.11.11:8001/<\/a>
\nRequestHeader set X-Forwarded-Proto “https”<\/p>\n
\nSSLCertificateKeyFile /etc/letsencrypt/live/PROXY.MYDOMAIN.COM/privkey.pem<\/p>\n
\n
\n<\/p>\n<\/a>end of line<\/h5>\n
\nand the wordpress site loads… kind’a. See the attachment.<\/p>\n