Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

icecast and lighttpd on port 80

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server
View previous topic :: View next topic  
Author Message
ct16k



Joined: 16 Apr 2010
Posts: 3

PostPosted: Fri Apr 16, 2010 8:45 am    Post subject: icecast and lighttpd on port 80 Reply with quote

I'm running lighttpd 1.4.22 on CentOS and recently Icecast 2.3.2 as well. I wanted to have the streaming server on the same port but mod_proxy didn't seem to do the job for me. While the pages were properly proxyed, the stream itself would not work (clients seemed to just hang waiting for data until eventually timing out). Plus, after I disconnected a client, I would find the connection between lighty and icecast still there.

Maybe there's a better way to do this, but my (lack of) searching skills couldn't help me find one, so here's how I do it now.

1. I wanted to use radio.example.com as the virtual domain for Icecast. Since I already had mod_simple_vhost enabled, I just created the docroot for it and placed the following code in there, as icecast.php:

Code:

<?php
ini_set('zlib.output_compression', 'Off');
ob_start();

if (!function_exists('apache_request_headers')) {
    eval('
        function apache_request_headers() {
            foreach($_SERVER as $key => $value) {
                if (substr($key, 0, 5) == "HTTP_") {
                    $key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
                    $out[$key] = $value;
                }
            }
            return $out;
        }
    ');
}

$query = $_SERVER['QUERY_STRING'];
$headers = apache_request_headers();

$fp = fsockopen("127.0.0.1", 8000);
fwrite($fp, "GET /$query HTTP/1.1\r\n");
foreach ($headers as $header => $value) {
    fwrite($fp, "$header: $value\r\n");
}
fwrite($fp,"\r\n");

ob_clean();
while (!feof($fp)) {
    $header = fgets($fp);
    if ($header == "\r\n")
        break;
    header(rtrim($header));
}

ob_end_flush();

while (!feof($fp)) {
    echo fread($fp, 4096);
    set_time_limit(0);
}

fclose($fp);
?>


2. I made sure mod_rewrite is loaded. Then I added the following lines to lighttpd.conf:

Code:

#                             )
$HTTP["host"] == "radio.example.com" {
    url.rewrite-once = (
        "^/(.*)" => "/icecast.php?$1"
    )
}


This will turn http://radio.example.com/live in http://radio.example.com/icecast.php?live which will in turn give you http://127.0.0.1:8000/live while also preserving the original HTTP request and response headers. I've been using it for a couple of days now and didn't find any problems so far so I thought I'd share it with the world.



Offtopic: Are yahoo and google email accounts not allowed? I tried registering with one of those and I got an error message saying they were banned.
Back to top
View user's profile Send private message
iunderwood



Joined: 23 Aug 2008
Posts: 114
Location: Leicester, MA

PostPosted: Sat Apr 17, 2010 3:32 pm    Post subject: Reply with quote

Icecast won't work proxied in that manner because it's always generating a continuous stream of data. The webpages that are finished actually complete which is why they show up.

Two daemons require two different ports available if you're using the same address on the system. However, if you have two IPs available to you, it should be somewhat simple to configure each application to work on one address only.
_________________
++I;
Back to top
View user's profile Send private message
ct16k



Joined: 16 Apr 2010
Posts: 3

PostPosted: Sat May 01, 2010 9:56 am    Post subject: Reply with quote

Actually, I'm expecting it to work with lighttpd 1.5 and mod_proxy, but I just haven't gotten around to testing it. Until then, as I've already stated above, the php "proxy" solution provided works great for me. Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber