0

Here's my situation:

I have a linux server from Scaleway hosting a SHOUTcast service, on the ip 1.2.3.4, port 8000 Recently I also rented a domain myserv.com so I can redirect the server to.

I changed the Nameserver to the ones provided by https://dns.he.net and started making records. Got an A record to point my domain to the IP address, and it's working fine. I can access my server by opening myserv.com:8000, but I'd like to access the SHOUTcast service with a subdomain, rather than adding the port. Let's say if I open sc.myserv.com it'll access 1.2.3.4:8000

I did some search and fount out I'd need to use SRV records, but I guess I didn't configure mine right cause it's not working. What am I doing wrong?

myserv.com. 86400 IN A 1.2.3.4
_shoutcast._tcp.sc.myserv.com. 86400 IN SRV 0 5 8000 myserv.com.

Thank you in advance

Brad
  • 159,648
  • 54
  • 349
  • 530
Marian
  • 191
  • 1
  • 4
  • 15

2 Answers2

2

No idea about Apache, but if you are running Nginx then this is really straightforward.

It's just a case of setting a proxy directive in your server configuration to route all requests to your subdomain to the Shoutcast server on your machine. Something along these lines:

server {
    server_name sc.myserv.com www.sc.myserv.com;
    location / {
        proxy_set_header        Host $host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto $scheme;
        proxy_pass              http://127.0.0.1:8000;
        proxy_read_timeout      90;
        proxy_redirect          off;
        proxy_buffering         off;
        tcp_nodelay             on;
    }
}

If your Shoutcast stats show your server IP address instead of the listeners IP then inside the server block but outside of the location block try adding:

set_real_ip_from <YOUR_SERVER_IP>;
real_ip_header X-Real-IP;
real_ip_recursive on;

You can also match requests using regex, which in turn makes the captured matches available as variables. So your location directive becomes:

location ~ /(.*) {

This will now capture anything you add to your proxied url. Then to pass the captured path along your proxy_pass becomes:

proxy_pass http://127.0.0.1:8000/$1;

or for some awkward clients you might want to specify it's an mp3 in the url, like this:

proxy_pass http://127.0.0.1:8000/$1/stream.mp3;

miknik
  • 5,748
  • 1
  • 10
  • 26
  • Are you getting the correct listener IP addresses passed to Shoutcast? My set up is a little different as I'm proxying the request between two servers and initially the Shoutcast logs showed every connection as originating from the proxy server IP. I've updated my answer with the fix. – miknik Feb 26 '18 at 20:03
  • On SHOUTcast I'm getting the listener IP as localhost, in parenthesis their actual IP. Aka `127.0.0.1 (11.22.33.44)` @miknik – Marian Feb 27 '18 at 12:13
  • Is the listener IP in parenthesis good enough for your use case? I can post my configs for both my servers if you want to try and fix it so the listener IP is the only one which is logged. It requires your Nginx install to have the `http_realip_module` installed, you can check by running this from the comand line `2>&1 nginx -V | tr -- - '\n' | grep http_realip_module` – miknik Feb 27 '18 at 19:14
  • It's not that big of a deal. But I am encountering an issue regarding playback. If a listener streams through a browser at `sc.myserv.com/1`, `/1` being a given channel, it's all good. But if done through a certain application, the stream distorts every second, unless they specify the port like `sc.myserv.com:8000/1`. User Agent of said application is `FMODEx/4.44.61` don't know how much that helps. – Marian Feb 27 '18 at 20:58
  • Edited my answer with a suggestion, let me know if it works – miknik Feb 28 '18 at 01:57
  • Oh boi, the more I look for, the more of a hassle it's becoming to remove the port from the address. So the solution above hasn't really worked, but I found another problem, this one might be more SHOUTcast related. You know how there's `http`, `v1.x` and `v2.x` direct URLs? `http` works fine, `v1.x` buffers for a second then stops, `v2.x` just doesn't load, but that one doesn't matter much. `FMODEx` are all v1 clients. But `v1.x` aren't buffering even if I have NGINX and proxy disabled. (Oops edit) – Marian Feb 28 '18 at 07:26
0

You can't use SRV records for this. There isn't client support.

If you want to access your SHOUTcast/Icecast/HTTP/HTTP-like service on its default port of 80, you need to use port 80, not 8000.

Brad
  • 159,648
  • 54
  • 349
  • 530