Having an Apache server is really a great thing, every day you can discover something new:D Today I discovered that I can use a reverse proxy to point to a server behind my firewall. Even better I can use a subdomain to access it, which is exactly what I need.
So let’s see, what I need is that every request to a certain subdomain to be mapped to another server, with a private IP-Address. This is great because I only expose parts of my server to the Network that I want.
First things first: in the apache configuration, which is usually located at /etc/sysconfig/apache2 edit the APACHE_OPTS to contain -D REVERSE, -D PROXY and -D PROXY_HTML (actually the last one’s not needed as we wont be adjusting any URLs, but let’s keep it anyway).
Now that we have enabled the proxy stuff, we can start configuring it. In the vhost directory (something like /etc/apache2/vhosts.d/) create a new file that will hold the configurationfor the subdomain:
<virtualhost your-ip-here>
DocumentRoot /srv/www/subdomain/htdocs
ServerName subdomain.domain.tld
ServerAdmin webmaster@subdomain.domain.tld
AccessFileName .htaccess
ScriptAlias /cgi-bin/ /srv/www/subdomain/cgi-bin/
ServerAlias subdomain.domain.tld sudomain
<directory /srv/www/subdomain/htdocs>
Order allow,deny
Allow from all
</directory><directory /srv/www/subdomain/cgi-bin>
AllowOverride None
Order allow,deny
Options ExecCGI
Allow from all
</directory></virtualhost>
Ok so by bow we have created the new subdomain, just to let apache shut up about missing folders we’ll create the required folder:
mkdir -p /srv/www/subdomain/{htdocs,cgi-bin}
What’s missing now? Right, the reverse Proxy so we have to add two new lines to the definition above:
Christian Decker wrote this at around evening time:
I love my music, I really do. Problem is however that I have far too much of it (2980 Songs, 16 GB currently, not counting audiobooks etc…) to carry it around with me all the time. It just doesn’t fit on my iPod Mini, nor does it fit on my notebook (I know shame on me, but I need the diskspace for work too). So I always have to carry around a selection of the songs I want to listen too, and far too often just the song I want to listen too is on my fileserver, and the trouble to transfer it to my notebook takes too long for me to be still in the mood to listen to it… Pitchfork is the solution to all of my problems, well almost all… Pitchfork allows me to stream my music over my Local Network, and over the internet, with a nice and responsive interface that facilitates access to my songs.
Installing MPD
Since Pitchfork is based upon MPD, which will take care of streaming the data to the various clients and maintain the song database, we will first have to set it up. Sadly my distro (OpenSuSe 10.2) doesn’t have a version of MPD in its package management, so I had to download the sources and compile it myself:
wget http://www.musicpd.org/uploads/files/mpd-0.12.2.tar.bz2
tar -xvjf mpd-0.12.2.tar.bz2
cd mpd-0.12.2/
Now we have the sources, and we have to check that we have all the dependencies. Depending on how you are going to use MPD you have to have the following packages (along with their devel packages):
libshout: because we will be streaming the songs to an Icecast server
oss: as far as I know this is the most widely used and best supported. If it doesnt work take a look here
libmad: for mp3 support
libogg: for OGG Vorbis support
libvorbis: for Metadata support for Vorbis formats
Quite a long list, but this is about the most essential stuff, if you have some special needs take a look at the official dependency listing.
Now it’s time to get to the actual compilation:
./configure
make
sudo make install
After the configure step, you’ll see a list of options that are turned on or off, if something is missing it probably means that you are missing some development packages.
So now we have mpd installed, the next step is to configure it. First you have to move the example configuration to the correct location:
sudo cp doc/mpdconf.example /etc/mpd.conf
Then we edit it according to our needs, especially the location of the Songs, Logfiles and Database should be changed:
music_directory "/storage/Music/"
playlist_directory "/storage/Music/playlists"
db_file "/var/lib/mpd.db"
log_file "/var/log/mpd.log"
error_file "/var/log/mpd.error"
pid_file "/var/run/mpd.pid"
The pid_file has to be uncommented since we will run MPD in daemon mode, and we want to shut it down later. Now let’s create these files and change the owners:
“mpd” being the user that will later run the daemon (if you don’t have an mpd user refer to your distro documentation on how to create one. It is really important that the mpd user is in the sour). Next we have to set some more settings:
user "mpd"
audio_output {type"oss"
name "Direct OSS output"}
audio_output {type"shout"
name "Icecast Stream"
host "localhost"
port "8000"
mount "/mpd.ogg"
password "youricecastpassword"
bitrate "96"
format "44100:16:1"}
mixer_type "oss"
mixer_device "/dev/mixer"
mixer_control "PCM"
mixer_type "software"
Initializing the database:
mpd --create-db
This will insert all your songs into the database for faster access. Now MPD is set up and should work. Try with
sudo mpd
MPD will complain that it can’t connect to the Icecast server (which we’ll setup a few lines below this, but everything else should work fine.
Installing Icecast
As I said, my Music resides on a fileserver, and I want the songs to be streamed directly to my other machines, so what’s better than Icecast, an opensource streaming solution, used by many internet radios out in the wild. Luckily most distros have it in their packagemanagement software (I know openSuSe has :D) so it shouldn’t be too hard to get it up and running, just make sure that the source password in /etc/icecast.xml matches the password you specified above, in the /etc/mpd.conf file.
Installing Pitchfork
Installing pitchfork is pretty straight forward. All you need is this:
Please refer to your distro documentation to see how to setup these. My setup uses an apache 2 server with mod_php, and Firefox 2 on my notebook. Now to the installation itself, depending on your distribution the document root of your webserver is /var/www/htdocs or /srv/www/htdocs, change to that directory and do the following:
wget http://pitchfork.remiss.org/files/pitchfork-0.5.2.tar.bz2
tar -xvjf pitchfork-0.5.2.tar.bz2
cd pitchfork-0.5.2/
chmod a+rwx config/
The rest of the configuration is done through the browser, just point your browser to http://localhost/pitchfork-0.5.2/ if you installed pitchfork on the computer you’re currently on, or replace localhot with the IP of your server. Change whatever you’d like to change (but it should not be necessary as the important configuration is done in MPD itself), and then press Save and you’ll be taken to the Pitchfork interface. Voila, it’s all done
Installing mpdscribble (optional)
I’m a huge fan of Last.fm, but sadly I can’t update my profile using the Player, because the songs are streamed to it. So why not use the MPD to update them for me? For this purpose I will be using mpdscribble:
wget http://www.frob.nl/projects/scribble/mpdscribble-0.2.12.tar.gz
tar -xvzf mpdscribble-0.2.12.tar.gz
cd mpdscribble-0.2.12
./configure
make
sudo make install
Now create the basic configuration
mkdir ~/.mpdscribble
It is suggested that mpdscribble is run as your user since it has read access to your username and password-hash. Edit the configuration file ~/.mpdscribble/mpdscribble.conf as follows:
username = "lastfm_username"
password = "md5sum of lastfm password"
Where the md5sum can be found using either this tool or the command line md5sum tool:
echo -n "your_lastfm_password" | md5sum
And that’s it, mpdscribble is set up and ready to be run:
Some great news from the Sxip team, who recently released their a beta of their service Sxipper, have released two libraries for OpenID:
Licensed under an open source Apache 2.0 license, Sxip has released the OpenID4Java and OpenID4Perl libraries. The libraries are easy-to-use and well-documented, allowing you to add full support for OpenID 1.x, 2.0 and Attribute Exchange into your Java and Perl based applications. We invite you to try them out and would appreciate your feedback! We also welcome and encourage community participation around the ongoing development of these libraries.
OpenID is an emerging Identity 2.0 authentication mechanism that enables users to maintain one login and password account for access to many sites. Package downloads for the latest version of the Java and Perl libraries for OpenID can be found on the distribution project page at code.sxip.com. In the coming weeks, we’ll update the library based on the progress of the OpenID Authentication 2.0 specification and we’re looking forward to working with others on the project!
I’m a huge fan of OpenID, and everything that helps implement the protocol easier is a step in the right direction.