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

Need help? Post your questions here.

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

Unread postby sukosevato » 31 Jan 2015, 19:07

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.
sukosevato
 
Posts: 4
Joined: 10 Oct 2013, 11:37
Has thanked: 1 time
Been thanked: 0 time

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

Unread postby DoCC » 01 Feb 2015, 11:15

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
User avatar
DoCC
Contributor
Contributor
 
Posts: 210
Joined: 25 Feb 2014, 14:41
Location: UpperBavaria : ))
Has thanked: 41 times
Been thanked: 71 times

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

Unread postby sukosevato » 02 Feb 2015, 17:49

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/n ... Player.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.
sukosevato
 
Posts: 4
Joined: 10 Oct 2013, 11:37
Has thanked: 1 time
Been thanked: 0 time

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

Unread postby cdoggs » 29 Mar 2015, 00:48

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.
cdoggs
 
Posts: 3
Joined: 20 Mar 2013, 16:54
Has thanked: 0 time
Been thanked: 0 time

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

Unread postby phooka » 09 Apr 2015, 11:23

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>
phooka
 
Posts: 3
Joined: 29 Jul 2013, 11:57
Has thanked: 1 time
Been thanked: 0 time

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

Unread postby Heruwar » 22 Apr 2015, 21:13

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>
Heruwar
 
Posts: 10
Joined: 09 May 2014, 21:37
Has thanked: 5 times
Been thanked: 7 times

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

Unread postby rynok » 03 Sep 2015, 20:41

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.
rynok
 
Posts: 1
Joined: 14 Aug 2014, 02:57
Has thanked: 0 time
Been thanked: 0 time

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

Unread postby Madevil » 04 Sep 2015, 14:07

This note is helpful to your problem viewtopic.php?f=62&t=1517#p5253

best regards
User avatar
Madevil
Administrator
Administrator
 
Posts: 909
Joined: 07 Dec 2012, 03:58
Has thanked: 1321 times
Been thanked: 951 times

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

Unread postby addseo1115 » 23 Jan 2016, 14:34

Thanks for the info
addseo1115
 


Return to Support 5.x

Who is online

Users browsing this forum: No registered users and 1 guest