squaremap

squaremap

1.9k Downloads

Reverse proxy fails when using external VPS with other services

FlitPix opened this issue ยท 2 comments

commented

My Minecraft server (mc.flitpix.net) is set up on a machine to which I only have console and FTP access. I have a separate VPS with full SSH access (flitpix.net), and I'd like to set up a reverse proxy on that using HTTPS to securely display the map. I would also like to use other services on this VPS, such as hosting my own website, so the existing reverse proxy documentation doesn't work for me.

Unfortunately, with my current setup, loading the map using the reverse proxy fails, with no content loading (this error occurs with all .js files, not just the ones displayed):

Selection_165

These are the relevant settings I have in my Apache VirtualHost:

<VirtualHost *:80>
        ServerName flitpix.net
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =flitpix.net
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
        ServerName flitpix.net
        DocumentRoot /var/www/flitpix.net/

        SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/flitpix.net/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/flitpix.net/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf

        SSLProxyEngine on
        ProxyRequests off
        ProxyPass "/mcmap" "http://mc.flitpix.net:port" nocanon
        ProxyPassReverse "/mcmap" "http://mc.flitpix.net:port"
</VirtualHost>

I haven't touched any relevant settings in apache2.conf.

Here is my config.yml.

commented

Edited to add more configuration info.

commented

The issue was with my reverse proxy - I had to add a trailing slash to the map in order to make it work: https://flitpix.net/mcmap/, rather than https://flitpix.net/mcmap.
I wrote a RewriteRule to redirect everyone to the URL with the trailing slash.

I'm most likely going to make additions to the Apache reverse proxy sections of the wiki at some point to help others who are configuring a manual setup.