I thought I’d write this up as I didn’t find it all the required info written down in one place when I was trying to do this myself. I wrote earlier on configuring Icecast. One concern when setting up a streaming media service is opening additional ports on a server – you may be unwilling or unable to do so for various reasons. If you already have Apache running you can use its proxying functionality to create a VirtualHost making Icecast available as part of your existing web services. An advantage of this is it also makes your streams potentially more available to people who use web proxies.
There are a couple of methods of configuring proxying. One is to use mod_rewrite – according to my reading this led to as issue where connections to the Icecast server were never closed once opened so available slots would quickly fill up even after people had stopped listening. This makes the preferable method mod_proxy/mod_proxy_http (these will need to be enabled in your Apache2 installation. Add a VirtualHost as follows:
<VirtualHost *:80>
ServerAdmin stream@example.org
ServerName stream.example.org
SetEnv downgrade-1.0 1
SetEnv force-response-1.0 1
ProxyRequests Off
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
Some notes: This config assumes your streaming server runs on port 8000 on the same host as Apache.
ProxyPass maps your subdomain name to your internal server. ProxyPassReverse adjusts URLs provided in HTTP redirects to prevent bypassing of the proxy.
Those SetEnv directives force the proxy to use HTTP 1.0 both ways rather than 1.1. Icecast uses HTTP 1.0 and there are known problems with proxying it over HTTP 1.1 such as track metadata being misinterpreted as part of the stream’s audio and causing interference.
The ProxyRequests Off line prevents your apache install being used as a standard forwarding proxy. This would probably be a bad thing if allowed.
The Location block sets access controls to the proxy. You can fine tune who gets to access the stream by domain or IP block. In its current state all are allowed.
Hi,
How do you configure the playlist generated by icecast to reflect the outside proxy instead of the internal one ?
Thanks
Hi Monk,
I see what you mean – localhost in the generated m3u file…
I would have thought the m3u would just contain the Stream URL (which is provided correctly below that…) Strange. I’ll have a look into it and post if I find anything.
@monk: Change the URLs in the internal Proxy* URLs to be the name of your externally facing host. I’ll call this for future reference. You will still have to include “:8000″ part.
Depending upon your network configuration, you may need to remap to 127.0.0.1 in your /etc/hosts file. I did, because my network though it needed to go out and come back in through the Firewall, which, I might add does not let traffic in on port 8000.
The only glitch I seem to have now is that the .m3u file also seems to want to include the port of the icecast server (8000), not the port of the Apache server (80 or 443). I am still working on this issue but hope to fix it soon!
Ugh the post system didn’t like me angled brackets…. second try:
Change the URLs in the internal Proxy* directives to be the name of your externally facing host (like http://www.tld.com), instead of localhost. I’ll call this EXT_HOSTNAME for future reference. You will still have to include “:8000? part. So the config ends up something like:
ProxyPass / http://EXT_HOSTNAME:8000/
ProxyPassReverse / http://EXT_HOSTNAME:8000/
Depending upon your network configuration, you may need to remap to 127.0.0.1 in your /etc/hosts file. I did, because my network thought it needed to go out and come back in through the Firewall, which, I might add does not let traffic in on port 8000. Setting EXT_HOSTNAME to map to 127.0.0.1 ensures that traffic forwarded from the apache HTTP server stays local to your machine.
The only glitch I seem to have now is that the .m3u file also seems to want to include the port of the icecast server (8000), not the port of the Apache server (80 or 443). I am still working on this issue but hope to fix it soon!
Nice one, munky. Thanks for that.
[...] public links >> icecast Proxying Icecast through Apache2 – another mini-HOWTO Saved by mileni on Sat 04-10-2008 Streamripper for Winamp Saved by whittrash101 on Wed [...]
I also could not solve the m3u problem.
Inside the m3u…
http://EXT_HOSTNAME:8000/xxxtestname
should be
http://{apachename}/xxxtestname
mod_rewrite might give a solution…
Any idea?
Try this:
AddOutputFilterByType fixplaylistport audio/x-mpegurl
ExtFilterDefine fixplaylistport mode=output cmd=”/bin/sed ’s/localhost:8000/localhost:80/g’”
Thanks infernix, will give it a shot.