Reverse proxying Mopidy-Party

Greetings everyone.

I’m currently busy with setting up the usual Mopidy+Snapcast multiroom setup.
Things are overall going smoothly: I’ve got Mopidy workiing with the Spotify and Local sources, Iris WebUI and Snapcast. Fantastic pieces of software, by the way.

I want all the web interfaces to be reverse proxy’ed through Apache, for architecture consistency in my network.
I’ve successfully implemented it for Iris, by taking inspiration from their GitHub Wiki.
My relevant Apache config pieces are as follows:

    <VirtualHost *:443>
        ServerName iris.xxxx
        ServerAdmin xxxx

        RewriteEngine on

        # Mopidy websocket
        ProxyPass /mopidy/ws/ ws://127.0.0.1:6680/mopidy/ws/
        ProxyPassReverse /mopidy/ws/ ws://127.0.0.1:6680/mopidy/ws/

        # Local-Images
        ProxyPass /images/ ws://127.0.0.1:6680/images/
        ProxyPassReverse /images/ ws://127.0.0.1:6680/images/

        # Iris websocket (Pusher)
        ProxyPass /iris/ws/ ws://127.0.0.1:6680/iris/ws/
        ProxyPassReverse /iris/ws/ ws://127.0.0.1:6680/iris/ws/

        # Iris HTTP endpoint
        ProxyPass /iris/ http://127.0.0.1:6680/iris/
        ProxyPassReverse /iris/ http://127.0.0.1:6680/iris/


        DocumentRoot "/usr/local/lib/python3.7/dist-packages/mopidy_iris/static"
        <Directory /usr/local/lib/python3.7/dist-packages/mopidy_iris/static>
                RewriteEngine on
                Require all granted
                Allow from all
                # rewite all requests at /iris/ (but NOT ./ws) to accommodate the
                # ./mopidy/{extension} URL format
                RewriteCond %{REQUEST_URI} !^/ws/
                RewriteRule ^iris/(.*)$ /$1 [L]
        </Directory>

        RequestHeader           set             X-Forwarded-Proto "https"
        ProxyPreserveHost       On
        ProxyRequests           Off

       [some SSL stuff]
</VirtualHost>

To be clear, that works. Now, on the same host, I want to set tup a second vHost that will reverse proxy Modipy-Party (which works like a charm when accessed from port 6680 directly).
I have devised the following config:

<VirtualHost *:443>
        ServerName party.srv.ev1z.be
        ServerAdmin eric.viseur@gmail.com

        RewriteEngine on

        # Mopidy websocket
        ProxyPass /mopidy/ws/ ws://127.0.0.1:6680/mopidy/ws/
        ProxyPassReverse /mopidy/ws/ ws://127.0.0.1:6680/mopidy/ws/

        DocumentRoot "/usr/local/lib/python3.7/dist-packages/mopidy_party/static"
        <Directory /usr/local/lib/python3.7/dist-packages/mopidy_party/static>
                RewriteEngine on
                Require all granted
                Allow from all
                # rewite all requests at /party/ (but NOT ./ws) to accommodate the
                # ./mopidy/{extension} URL format
                RewriteCond %{REQUEST_URI} !^/ws/
                RewriteRule ^party/(.*)$ /$1 [L]
        </Directory>

        RequestHeader           set             X-Forwarded-Proto "https"
        ProxyPreserveHost       On
        ProxyRequests           Off

        [Some SSL stuff]
</VirtualHost>

As you’ve guessed, it does not work.
The Party UI loads but it cannot connect to Mopidy, as confirmed by the Apache log:

xxxx - - [26/Aug/2020:09:48:12 +0200] "GET /mopidy/ws HTTP/1.1" 400 756 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"

So, my question is simple: what am I missing ?

Alright, if anyone stumbles upon this: the solution was to remove the trailing slash in the ProxyPass(Reverse) for the Mopidy Websocket. I realized this by comparing Apache logs: Iris accesses the WS with a trailing slash, Party does not.

1 Like