如何将Scaleway上的SHOUTcast服务器重定向到子域名?
Hey there, let's get your SHOUTcast service accessible via a clean subdomain (like radio.myserv.com) instead of typing the port number every time. Here's a step-by-step guide tailored to your setup:
1. Add a Subdomain DNS Record
First, you need to point your desired subdomain to your Scaleway server IP:
- Log into your HE.NET DNS management panel
- Create a new A Record with:
- Hostname: Your preferred subdomain (e.g.,
radio) - Target:
1.2.3.4(your server's IP)
- Hostname: Your preferred subdomain (e.g.,
- Save the record and wait for DNS propagation (this can take 5-30 minutes, sometimes longer depending on TTL settings)
2. Set Up a Reverse Proxy with Nginx
The easiest way to map the subdomain to your SHOUTcast port is using a reverse proxy. We'll use Nginx here (it's lightweight and widely supported):
Install Nginx (if not already installed)
Run these commands based on your Linux distro:
- For Debian/Ubuntu:
sudo apt update && sudo apt install nginx -y - For RHEL/CentOS/Fedora:
sudo dnf install nginx -y
Create a Custom Nginx Configuration File
Create a new config file for your subdomain:
sudo nano /etc/nginx/sites-available/radio.myserv.com
Paste this configuration (replace radio.myserv.com with your actual subdomain):
server { listen 80; server_name radio.myserv.com; location / { # Proxy requests to your SHOUTcast service on port 8000 proxy_pass http://127.0.0.1:8000; # Pass necessary headers to SHOUTcast proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Disable buffering to support smooth streaming proxy_buffering off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }
Enable the Configuration and Restart Nginx
- Link the config file to the enabled sites directory:
sudo ln -s /etc/nginx/sites-available/radio.myserv.com /etc/nginx/sites-enabled/ - Test the Nginx configuration for syntax errors:
sudo nginx -t - If you see "test is successful", restart Nginx to apply changes:
sudo systemctl restart nginx
3. Update SHOUTcast Configuration (Critical!)
SHOUTcast might block proxy requests by default, so adjust its settings:
- Open your SHOUTcast config file (usually
sc_serv.confin your SHOUTcast directory) - Find the
AllowRelaysetting and set it to:AllowRelay=Yes - Save the file and restart your SHOUTcast service to apply changes.
4. (Optional) Add HTTPS for a Secure Connection
If you want your subdomain to use https:// instead of http://, use Certbot to get a free SSL certificate:
- Install Certbot and the Nginx plugin:
sudo apt install certbot python3-certbot-nginx -y # Debian/Ubuntu # OR sudo dnf install certbot python3-certbot-nginx -y # RHEL/CentOS/Fedora - Run Certbot to configure SSL automatically:
sudo certbot --nginx -d radio.myserv.com
Follow the on-screen prompts, and Certbot will update your Nginx config to use HTTPS and set up auto-renewal for the certificate.
Verify the Setup
Once DNS propagation is complete, open your browser and visit http://radio.myserv.com (or https:// if you set up SSL). You should see your SHOUTcast service without needing to append the :8000 port.
内容的提问来源于stack exchange,提问作者Marian

