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
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;