Adding Custom Header to Logout in Icecast

9/13/2018

Is it possible to have the log output for icecast read a variable from a header sent to the server? Currently I am setting up an icecast server in Kuberenetes and I'm trying to get source IP preservation onto the stream for analyzing log data. However even with the necessary steps on kubernetes side I am not seeing the logs for icecast have source IP. How ever I was able to sniff incoming request and I am seeing:

X-Real-IP: 142.x.x.x
X-Forwarded-For: 142.x.x.x

As headers coming into the server.

Is it possible to get these into the logs somehow?

-- Pablo Marti Cordero
google-cloud-platform
icecast
kubernetes
networking

2 Answers

9/13/2018

Not at the moment.

We plan to support reverse proxying in release 2.5.

Our general recommendation at the moment is to not reverse proxy Icecast due to many possible problems beyond just losing the originating IP address.

Just expose the Icecast ports directly to the Internet, e.g. through port forwarding.

edit: You can just declare protocol: TCP ports for your service. also "Proxy-mode: iptables"

-- TBR
Source: StackOverflow

9/20/2018

If you don't mind a little tinkering you can do it.

Clone the source

Find these lines in the source files, which define what is logged as listener ip:

./src/logging.c:159: client->con->ip,
./src/admin.c:700: xmlNewTextChild(node, NULL, XMLSTR(mode == OMODE_LEGACY ? "IP" : "ip"), XMLSTR(client->con->ip)); 

Add this snippet to define a new variable, this will be set to value of X-Real-IP header if present or client IP if not:

const char *realip;
realip = httpp_getvar (client->parser, "x-real-ip");
if (realip == NULL)
  realip = client->con->ip;

Change the previously mentioned lines to reference the new variable:

./src/logging.c:163: realip,
./src/admin.c:700: xmlNewTextChild(node, NULL, XMLSTR(mode == OMODE_LEGACY ? "IP" : "ip"), XMLSTR(realip));

Build Icecast from source as per the instructions

-- miknik
Source: StackOverflow