Howto Subsonic within FreeBSD Jail + Redirect with Apache

Tutorials, tips and tricks.

Moderator: moderators

Howto Subsonic within FreeBSD Jail + Redirect with Apache

Postby zilfrid » Sat May 15, 2010 4:52 am

Install:
diablo-jdk-1.6.0.07.02_9 Java Development Kit 1.6.0_07.02 [WITH_JAIL=true]
jdk-1.6.0.3p4_15 Java Development Kit 1.6.0
servlet-api-2.5_3
tomcat-6.0.26 Open-source Java web server by Apache, 6.x branch

Enable startup services
# echo 'tomcat60_enable="YES"' >> /etc/rc.conf
### Options for JVM ####
# echo 'tomcat60_java_opts="-Djava.net.preferIPv4Stack=true -server -Xmn128M -Xmx256M -Xms256M"'>> /etc/rc.conf

The first line enables the RCng init script—this init script has code that will not try
to start Tomcat unless the tomcat60_enable variable is enabledthis way, to prevent
Tomcat from accidentally starting at boot time. Adding the second line will avoid a
problem that prevents Tomcat from opening its TCP server ports.


Enable Tomcat's Manager
# vi /usr/local/apache-tomcat-6.0/conf/tomcat-users.xml
<tomcat-users>
<!--
NOTE: By default, no user is included in the "manager" role required
to operate the "/manager" web application. If you wish to use this app,
you must define such a user - the username and password are arbitrary.
-->
<user name="YOU" password="YOUR_PASSWORD" roles="standard,manager" />
</tomcat-users>


Start tomcat server:

# /usr/local/etc/rc.d/tomcat6 start

Setup subsonic
Code: Select all
mkdir /var/subsonic /var/music /var/playlists
chown -R www:www /var/subsonic
chown -R www:www /var/music
chown -R www:www /var/playlists


Open your http://localhost:8180/ and log in to Tomcat Manager and go to:

WAR file to deploy
Select WAR file
Code: Select all
to upload      /your path/ subsonic.war


http://localhost:8180/subsonic
Enjoy

Note:
* Restart your jail after have scanned your /var/music path to see yours thumbnails (covers .. artworks)
    Install lame, faad, ffmpeg, transcode etc... if you need resample your tracks! or using video
Example:
    Enable lame within Subsonic
# ln -s /usr/local/bin/lame /var/subsonic/transcode/



Redirection whith apache22 + mod_proxy


    1 - Modiffy:


edit: /usr/local/apache-tomcat-6.0/conf/server.xml
Code: Select all
<Connector port="8180" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
              + proxyName="your_virtual_host.org"
              + proxyPort="80" />


    2 - I redirect my path to have "Subsonic" instead of Tomcat "root page"
    I backup and change :
edit /usr/local/apache-tomcat-6.0/webapps/ROOT/index.html

Code: Select all
<html>
<head>
<title>Redirection vers Subsonic</title>
<meta http-equiv="Refresh" content="0;URL=subsonic">
</head>
<body>
<center>
<table height="100%">
<tr><td>
<center>
<a href="subsonic">Subsonic</a>
</center>
</td></tr>
</table>
</center>
</body>
</html>

    3 - configure vhost on my webserver


edit : /usr/local/etc/apache22/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerName your_virtual_host.org

# Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts)
ProxyRequests Off
ProxyPreserveHost On

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass / http://your_virtual_host.org:8180/
ProxyPassReverse / http://your_virtual_host.org:8180/

# SetEnv force-proxy-request-1.0 1
# SetEnv proxy-nokeepalive 1

<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>


Another solution apache22 + mod_ajp

in your httpd.conf add:
LoadModule proxy_ajp_module libexec/apache22/mod_proxy_ajp.so


edit : /usr/local/etc/apache22/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerName your_virtual_host.org
ErrorLog "/var/log/www/your_virtual_host.org/error.log"
CustomLog "/var/log/www/your_virtual_host.org/access.log" common

# Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts)
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass / ajp://1.2.3.4:8009/
ProxyPassReverse / ajp://1.2.3.4:8009/

<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>


Tomcat configuration
edit : /usr/local/apache-tomcat-6.0/conf/server.xml

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
zilfrid
 
Posts: 6
Joined: Wed May 12, 2010 1:45 pm

Postby evandena » Fri Aug 20, 2010 3:11 pm

I'll give this a shot this weekend.
Is everything still current?
evandena
 
Posts: 18
Joined: Mon Apr 13, 2009 12:57 am


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 12 guests