Integrating Subsonic into existing Apache Web Space

Tutorials, tips and tricks.

Moderator: moderators

Integrating Subsonic into existing Apache Web Space

Postby organon » Mon Feb 09, 2009 6:08 pm

If anyone would like to integrate their Subsonic interface into their regular web space (as opposed to people going to your host on the specific port you have configured for Subsonic - e.g. http://www.yourdomain.org:8080), a couple of lines in the Apache config file if you have enabled the Apache mod_proxy module (I'm less familiar with IIS, but there appears to be several reverse proxy tools out there for it), and you're off to the races.

I run Subsonic on a CentOS 5 Linux host, running Apache 2.2

The default config file for the Apache instance (adjust as per your Apache configuration) is: /etc/httpd/conf/httpd.conf
I have installed Subsonic under /opt/subsonic, and the *NIX shell script to start the server is therefore: /opt/subsonic/subsonic.sh

I have added the following two lines to my Apache config:
Code: Select all
ProxyPass           /groovy http://localhost:8080/groovy
ProxyPassReverse    /groovy http://localhost:8080/groovy


That configuration needs to be matched in the Subsonic config file with this directive:
Code: Select all
SUBSONIC_CONTEXT_PATH=/groovy


Reload the Apache config file:
Code: Select all
service httpd reload
in CentOS, and restart the Subsonic server, and you should be able to get at your Subsonic interface via:

http://www.yourdomain.org/groovy

This has one effect that people may like or dislike. Whereas the Players in Subsonic may be associated with a dynamic IP of the user if they are accessing the application directly (e.g. at http://www.yourdomain.org:8080 in my above example), all players will be considered as coming from the loopback (127.0.0.1) address as far as Subsonic is concerned when configuring this kind of setup.

On the security side, it's one less port you need to expose directly, and there are many of the mod_security directives you can use to help protect the server/application anyway.

Good luck!
User avatar
organon
 
Posts: 7
Joined: Sun Feb 08, 2009 10:43 pm

Postby donpearson » Sun Feb 22, 2009 5:20 pm

one thing, in the windows install you set the Subsonic config
Code: Select all
SUBSONIC_CONTEXT_PATH=/groovy


in the program that runs in the toolbar
Facebook Group:
http://www.facebook.com/groups/subsonic.group/

Image
donpearson
 
Posts: 361
Joined: Wed Oct 15, 2008 3:53 pm
Location: UK

Postby mancubus220 » Fri Mar 06, 2009 5:17 pm

does this method work with tomcat as well or is there a more preferred way to do it for tomcat?
mancubus220
 
Posts: 7
Joined: Fri Mar 06, 2009 3:51 pm

Postby jonathanroz » Sat Apr 18, 2009 9:35 pm

Has anyone that has implemented this observered any performance or server utilization issues after switching to using a proxy?

I am currently using it only in a limited fashion for people that have problems accessing my site from a corporate LAN due to the non standard port.
jonathanroz
 
Posts: 172
Joined: Thu Dec 18, 2008 8:54 pm
Location: Frisco, TX USA

Postby jigsaw » Sun Apr 19, 2009 9:28 am

jonathanroz wrote:Has anyone that has implemented this observered any performance or server utilization issues after switching to using a proxy?

I've used it for some time now and haven't experienced any problems with performance. I also have experience using mod_proxy at my business which has websites with thousands of connections daily, and we don't see any performance issues there either..
Currently without Subsonic due to hardware failure :(
User avatar
jigsaw
 
Posts: 242
Joined: Sat Oct 13, 2007 12:01 pm
Location: Stavanger, Norway

Postby kamaradclimber » Fri May 29, 2009 8:25 am

hello,

i've followed instructions for setting up subsonic on my apache2 server (debian)
but when i want to access to http://myip/subsonic the server answers with 403 error

i don't understand what to do

in a nutshell, here's my conf:

files are in /opt/subsonic
subsonic_home is /var/subsonic
context path is /subsonic

my etc/apache2/httpd.conf is composed of two lines :
ProxyPass /subsonic http://localhost:8080/subsonic
ProxyPassReverse /subsonic http://localhost:8080/subsonic


thank you for help :-)
kamaradclimber
 
Posts: 6
Joined: Fri May 29, 2009 8:19 am

Postby jonathanroz » Fri May 29, 2009 4:16 pm

Kamaradclimber,

If you are using Apache2 instead of Apache2.2 then there are some different steps.

First you have to enable the proxy_http module in Apache2

Debian instructions to do this are here: http://www.debuntu.org/book/export/html/72

After the mod is enabled you should see the below 3 files in your mods_enabled folder
proxy.conf
proxy.load
proxy_http.load

Open your proxy.conf file and edit it so it is similar to mine. Of course you have to update the IP, Port and Path to match your configuration.

I have 2 Subsonics running, one on the local machine and one on a different machine. You can see examples of each one in my config file.

Code: Select all
<IfModule mod_proxy.c>
        #turning ProxyRequests on and allowing proxying from all may allow
        #spammers to use your proxy to send email.

ProxyRequests Off



<Proxy *>



Order deny,allow

Allow from all



</Proxy>



ProxyPass /music http://localhost:88/music

ProxyPassReverse /music http://localhost:88/music

ProxyPass /subsonic http://192.168.1.45:89/subsonic

ProxyPassReverse /subsonic http://192.168.1.45:89/subsonic

        # Enable/disable the handling of HTTP/1.1 "Via:" headers.
        # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
        # Set to one of: Off | On | Full | Block

        ProxyVia On
</IfModule>



I hope this helps
jonathanroz
 
Posts: 172
Joined: Thu Dec 18, 2008 8:54 pm
Location: Frisco, TX USA

Postby kamaradclimber » Tue Jun 02, 2009 2:25 pm

thank you for your answer

i've activated the proxy_http mod and used your conf file

but it still does not work, even if the issue has changed:
Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
kamaradclimber
 
Posts: 6
Joined: Fri May 29, 2009 8:19 am

Postby jonathanroz » Tue Jun 02, 2009 10:38 pm

Kamaradclimber,

That is actually a good thing that your error changed because that means the Proxy is at least trying to forward the traffic but it cannot get there so is giving an error back.

Sometimes I get that when I am trying to access the subsonic I have running in Tomcat and have to stop Tomcat and wait 2 or 3 minutes and the start it again.

A couple of thoughts.

1) I would make sure you remove the lines you added in httpd.conf just to make sure that is not causing the issue.

2) I am assuming that you still have these listed assuming you are using subsonic as your path for the Subsonic server and not /music or /

I also am assuming that the subsonic service is running on the machine your Apache server is on.

ProxyPass /subsonic http://localhost:8080/subsonic
ProxyPassReverse /subsonic http://localhost:8080/subsonic

If so can you open a browser to http://localhost:8080/subsonic and get to the service? If not then you might have another issue.

3) I have seen a lot of people have issues with port 8080 because of a conflict with the management port for their router. You might want to try a different port.
jonathanroz
 
Posts: 172
Joined: Thu Dec 18, 2008 8:54 pm
Location: Frisco, TX USA

Postby kamaradclimber » Wed Jun 03, 2009 7:00 am

thank you again for your answer, i appreciate your support :-)

unfortunately, the issue has come back to the first point and i'm unable to fix it again

i think i'm going to purge everything of apache and restart from scratch, is it a good idea ?
kamaradclimber
 
Posts: 6
Joined: Fri May 29, 2009 8:19 am

Postby kamaradclimber » Sun Jun 07, 2009 9:08 am

ok, i've started from scratch (purge apache and reinstall)

subsonic is in /var/subsonic/standalone

subsonic.sh is:
SUBSONIC_HOME=/var/subsonic/standalone
SUBSONIC_HOST=0.0.0.0
SUBSONIC_PORT=8080
SUBSONIC_CONTEXT_PATH=/music
SUBSONIC_MAX_MEMORY=64
SUBSONIC_PIDFILE=

my httpd.conf (apache user conf file) contains
ProxyPass /music http://localhost:8080/music
ProxyPassReverse /music ...

there are two errors messages:

fist when i'm trying to connect to http://impossible.doesntexist.com:8080 (my domain)
HTTP ERROR: 404

NOT_FOUND

RequestURI=/

Powered by jetty://


then:

if i try to reload apache conf with etc/init.d/apache2 reload (or restart)

i get :
Reloading web server config: apache2[Sun Jun 07 11:09:09 2009] [warn] worker http://localhost:8080/music already used by another worker


you said that's great when error messag changes, so what is the problem now ?
thanks you again for your help, i think we will succeed :-)
kamaradclimber
 
Posts: 6
Joined: Fri May 29, 2009 8:19 am

Postby jonathanroz » Sun Jun 07, 2009 1:54 pm

So are you able to access subsonic from the local machine by going to http://localhost:8080/music
jonathanroz
 
Posts: 172
Joined: Thu Dec 18, 2008 8:54 pm
Location: Frisco, TX USA

Postby kamaradclimber » Sun Jun 07, 2009 2:48 pm

actually yes
that's a good point
kamaradclimber
 
Posts: 6
Joined: Fri May 29, 2009 8:19 am

Postby jonathanroz » Sun Jun 07, 2009 9:59 pm

OK I am able to get to your site using :8080 which is good.

Did you say you added your ProxyPass statement to your httpd.conf file?

My setup in Apache 2 has the httpd.conf file complete empty. I dont use that for anything (not 100% sure if that is how it has to be but it works for me). I have my proxy info in the proxy.conf file located in the mods-enabled folder.

Can you remove whatever you added in httpd.conf and update your proxy.conf file to show exactly what I have below.

Afterwards you will have to restart Apache.

Code: Select all
<IfModule mod_proxy.c>
        #turning ProxyRequests on and allowing proxying from all may allow
        #spammers to use your proxy to send email.

ProxyRequests Off


<Proxy *>


Order deny,allow

Allow from all


</Proxy>


ProxyPass /music http://localhost:8080/music

ProxyPassReverse /music http://localhost:8080/music


        # Enable/disable the handling of HTTP/1.1 "Via:" headers.
        # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
        # Set to one of: Off | On | Full | Block

        ProxyVia On
</IfModule>
jonathanroz
 
Posts: 172
Joined: Thu Dec 18, 2008 8:54 pm
Location: Frisco, TX USA

Postby kamaradclimber » Mon Jun 08, 2009 5:47 am

there is no change, the same error message appears if i try to restart the apache server
(but it doesnt stop if i say so)

it doesnt matter, if subsonic works i'm happy
thanks you a lot !
kamaradclimber
 
Posts: 6
Joined: Fri May 29, 2009 8:19 am

Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests