Apache reverse proxy madsonic, can't get it to work.

Need help? Post your questions here.
sukosevato
Posts: 3
Joined: 10 Oct 2013, 11:37
Has thanked: 0
Been thanked: 0

Apache reverse proxy madsonic, can't get it to work.

Unread post by sukosevato »

Hey,

I can't get madsonic working together with Apache functioning as reverse proxy.

I put apache as a reverse proxy in front of all my webinterfaces. I also add basic authentication to it so that people first need to authenticate to apache before they can connect to the webinterface. This is a huge security advantage since attackers can't mess with any of my webinterfaces unless they've first authenticated to apache. This how ever is not possible if the web interface it self is already using http basic authentication, since you can't chain two of those together. Unfortunately madsonic is using basic authentication, so I can't do that. (couchpotato, sickrage, roundcube, owncloud, postfixadmin, etc... all use a different form of authentication with cookies). Nevertheless, I do want apache in front of madsonic as a reverse proxy because I think the ssl stack of apache is a lot more bullet proof since I can configure which ciphers to use etc..

But I can't get that to work :p

Code: Select all

    ProxyPass /madsonic http://10.0.1.2:4040
    ProxyPassReverse /madsonic http://10.0.1.2:4040
    ProxyRequests off  #do not just proxy all requests like a forward proxy
    ProxyPreserveHost off
This kinda works, except half of the stuff madsonic references is broken. See the following image for clarification:

http://i.imgur.com/3DkPJvQ.png

If I open up the developer console in firefox I see tons of:

"GET https://$url:$port/style/simplify.css 404"
"GET https://$url:$port/icons/default/gpl.png 404"
"GET https://$url:$port/script/scripts.js 404"

Do I need to be rewriting things for this to work? Does anyone else succesfully have apache reverse proxy madsonic?

Thanks in advance.
User avatar
DoCC
Contributor
Contributor
Posts: 211
Joined: 25 Feb 2014, 14:41
Has thanked: 40 times
Been thanked: 65 times

Re: Apache reverse proxy madsonic, can't get it to work.

Unread post by DoCC »

this works fine.

Code: Select all

<VirtualHost 192.168.2.3:80>
    ServerName music.power-server.at
	ProxyPass / http://192.168.0.3:4040/
	ProxyPassReverse / http://192.168.0.3:4040/
</VirtualHost>
since madsonic has its own usermanagement, you do not need a pre authentication.
and due to routing from an external interface to an internal. they can't mess around, cause the rout / proxy will brake up.

but i know your problem ...
madsonics call to elements are path absolute and not relative. so without mapping this proxy to "root" -> / the styling and other stuff will end up in 404
sukosevato
Posts: 3
Joined: 10 Oct 2013, 11:37
Has thanked: 0
Been thanked: 0

Re: Apache reverse proxy madsonic, can't get it to work.

Unread post by sukosevato »

I got it semi working with the following config:

Code: Select all

    ProxyPass /madsonic http://10.0.1.2:4040
    ProxyPassReverse /madsonic http://10.0.1.2:4040
    ProxyHTMLEnable on
    ProxyHTMLURLMap / /madsonic/ ^ 
All images load and work fine, but all references via javascript are broken. Can't think of a way to fix that.

POST https://$url:$port/dwr/call/plaincall/nowPlayingService.getNowPlayingForCurrentPlayer.dwr 404

So yea... I'm giving up on this for now and I'll simply run it on a different port without the /madsonic suffix. But it should be possible to get it working with that suffix.
since madsonic has its own usermanagement, you do not need a pre authentication.
I disagree with that. Madsonic is a small project and there is a large chance there are security bugs in it. Apache which is deployed by a significantly larger user base is most likely a much harder target to break into than madsonic. So I prefer first authenticating with Apache before you're allowed to Authenticate with Madsonic. It's security in depth.
cdoggs
Posts: 3
Joined: 20 Mar 2013, 16:54
Has thanked: 0
Been thanked: 0

Re: Apache reverse proxy madsonic, can't get it to work.

Unread post by cdoggs »

Here's a piece of my config;

# Madsonic
ProxyPass /mad/ http://127.0.0.1:4040/
ProxyPassReverse /mad/ http://127.0.0.1:4040/
ProxyPass /script/ http://127.0.0.1:4040/script/
ProxyPassReverse /script/ http://127.0.0.1:4040/script/
ProxyPass /flash/ http://127.0.0.1:4040/flash/
ProxyPassReverse /flash/ http://127.0.0.1:4040/flash/
ProxyPass /icons/ http://127.0.0.1:4040/icons/
ProxyPassReverse /icons/ http://127.0.0.1:4040/icons/
ProxyPass /jam/ http://127.0.0.1:4040/jam/
ProxyPassReverse /jam/ http://127.0.0.1:4040/jam/
ProxyPass /style/ http://127.0.0.1:4040/style/
ProxyPassReverse /style/ http://127.0.0.1:4040/style/
ProxyPass /stream http://127.0.0.1:4040/stream
ProxyPassReverse /stream http://127.0.0.1:4040/stream
ProxyPass /dwr/ http://127.0.0.1:4040/dwr/
ProxyPassReverse /dwr/ http://127.0.0.1:4040/dwr/
ProxyPass /rest/ http://127.0.0.1:4040/rest/
ProxyPassReverse /rest/ http://127.0.0.1:4040/rest/
ProxyHTMLURLMap http://127.0.0.1:4040/ /mad/
<Location /mad/>
<LimitExcept PROPFIND>
Require all granted
</LimitExcept>
ProxyPassReverse /
SetOutputFilter proxy-html
ProxyHTMLURLMap http://127.0.0.1:4040/ /mad/
ProxyHTMLURLMap / /mad/
ProxyHTMLURLMap /mad/ /mad/
RequestHeader unset Accept-Encoding
</Location>
<Location /dwr/>
<LimitExcept PROPFIND>
Require all granted
</LimitExcept>
</Location>
<Location /stream>
<LimitExcept PROPFIND>
Require all granted
</LimitExcept>
</Location>
<Location /script/>
<LimitExcept PROPFIND>
Require all granted
</LimitExcept>
</Location>
</VirtualHost>

This WORKS! I use it with android app for both music and video as well as the website for both as well including transcoding.
phooka
Posts: 3
Joined: 29 Jul 2013, 11:57
Has thanked: 1 time
Been thanked: 0

Re: Apache reverse proxy madsonic, can't get it to work.

Unread post by phooka »

Dirty workaround I use with apache & 5.1:

Code: Select all

    <LocationMatch ^/icons/.+/.+>
        Satisfy any
        RedirectMatch ^/icons/(.*) /madsonic/icons/$1
    </LocationMatch>
    <LocationMatch ^/script/.+/*.*>
        Satisfy any
        RedirectMatch ^/script/(.*) /madsonic/script/$1
    </LocationMatch>
Heruwar
Posts: 10
Joined: 09 May 2014, 21:37
Has thanked: 3 times
Been thanked: 7 times

Re: Apache reverse proxy madsonic, can't get it to work.

Unread post by Heruwar »

cdoggs wrote: ProxyPass /mad/ http://127.0.0.1:4040/
ProxyPassReverse /mad/ http://127.0.0.1:4040/
ProxyPass /script/ http://127.0.0.1:4040/script/
ProxyPassReverse /script/ http://127.0.0.1:4040/script/
ProxyPass /flash/ http://127.0.0.1:4040/flash/
ProxyPassReverse /flash/ http://127.0.0.1:4040/flash/
ProxyPass /icons/ http://127.0.0.1:4040/icons/
ProxyPassReverse /icons/ http://127.0.0.1:4040/icons/
ProxyPass /jam/ http://127.0.0.1:4040/jam/
ProxyPassReverse /jam/ http://127.0.0.1:4040/jam/
ProxyPass /style/ http://127.0.0.1:4040/style/
ProxyPassReverse /style/ http://127.0.0.1:4040/style/
ProxyPass /stream http://127.0.0.1:4040/stream
ProxyPassReverse /stream http://127.0.0.1:4040/stream
ProxyPass /dwr/ http://127.0.0.1:4040/dwr/
ProxyPassReverse /dwr/ http://127.0.0.1:4040/dwr/
ProxyPass /rest/ http://127.0.0.1:4040/rest/
ProxyPassReverse /rest/ http://127.0.0.1:4040/rest/
ProxyHTMLURLMap http://127.0.0.1:4040/ /mad/
Is this supposed to fix images/css and such not working when serving madsonic on something other than / ?

If so, you can fix this in madsonic.properties by setting UrlRedirectContextPath=mad instead, which is a lot less ugly.

Afterwards this should be enough to get reverse proxy working with /madsonic for example

Code: Select all

<Location /madsonic>
    ProxyPass http://127.0.0.1:4040/madsonic
    ProxyPassReverse http://127.0.0.1:4040/madsonic
</Location>
These users thanked the author Heruwar for the post:
DoCC
Rating: 7.69%
rynok
Posts: 1
Joined: 14 Aug 2014, 02:57
Has thanked: 0
Been thanked: 0

Re: Apache reverse proxy madsonic, can't get it to work.

Unread post by rynok »

Heruwar wrote: Is this supposed to fix images/css and such not working when serving madsonic on something other than / ?

If so, you can fix this in madsonic.properties by setting UrlRedirectContextPath=mad instead, which is a lot less ugly.

Afterwards this should be enough to get reverse proxy working with /madsonic for example

Code: Select all

<Location /madsonic>
    ProxyPass http://127.0.0.1:4040/madsonic
    ProxyPassReverse http://127.0.0.1:4040/madsonic
</Location>
I've tried to configure according to this, but it's not working quite as expected.
User avatar
Madsonic
Administrator
Administrator
Posts: 984
Joined: 07 Dec 2012, 03:58
Answers: 7
Has thanked: 1201 times
Been thanked: 470 times

Re: Apache reverse proxy madsonic, can't get it to work.

Unread post by Madsonic »

This note is helpful to your problem http://forum.madsonic.org/viewtopic.php ... 1517#p5253

best regards
addseo1115
Has thanked: 0
Been thanked: 0

Re: Apache reverse proxy madsonic, can't get it to work.

Unread post by addseo1115 »

Thanks for the info
Post Reply