milaq / YCast

Self hosted vTuner internet radio service emulation
Other
240 stars 93 forks source link

apache2-ycast.conf.example #108

Closed dkarnout closed 2 years ago

dkarnout commented 2 years ago

Hi! I would be glad if there could be an apache2-ycast.conf.example like nginx-ycast.conf.example, while i am a server noob, my home server runs already apache2 and i would not load it with so many services. I would like to test it using a Marantz NA7004.

The following does a 'Server Error' on NA7004's screen. Thanks in advance!


<VirtualHost _default_:80>
  ServerName marantz.vtuner.com
  ServerAlias denon.vtuner.com
  ServerAlias denon2.vtuner.com
  <Location />
    ProxyPreserveHost On
    RequestHeader set X-Real-IP expr=%{REMOTE_ADDR}
    RequestHeader set X-Forwarded-For expr=%{REMOTE_ADDR}
    RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}

    ProxyPass http://127.0.0.1:8010/
    ProxyPassReverse http://127.0.0.1:8010/
  </Location>
  ErrorLog ${APACHE_LOG_DIR}/error.vtuner.log
  CustomLog ${APACHE_LOG_DIR}/access.vtuner.log combined
</VirtualHost>
dkarnout commented 2 years ago

UPDATE if it helps: The following does not a 'Server Error' anymore, but shows 'Internet radio' and does not show 'Search by genre', etc: I believe my error is at X-Forwarded-For...


<VirtualHost _default_:80>
  ServerName marantz.vtuner.com
  ServerAlias radiomarantz.com
  <Location />
    ProxyPreserveHost On
    RequestHeader set X-Real-IP %{REMOTE_ADDR}s
    RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
    RequestHeader set X-Forwarded-Proto %{REQUEST_SCHEME}s
 #          proxy_redirect  off;
 #          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;
    ProxyPass http://127.0.0.1:8010/
    ProxyPassReverse http://127.0.0.1:8010/
  </Location>
  ErrorLog ${APACHE_LOG_DIR}/error.vtuner.log
  CustomLog ${APACHE_LOG_DIR}/access.vtuner.log combined
</VirtualHost>
SpeedyGoneZales commented 2 years ago

It's not directly related to the apache2 config, but when I brought up a virtual machine on CentOs 9 recently, I ran into trouble with running yCast on the local loopback interface and firewalld. The workaround was to not tie yCast to the localhost interface, and use firewalld to redirect port 80 like so:

yCast

/usr/bin/python3 -m ycast -p 8010 -c /etc/ycast/stations.yaml -d   

(note how -l 127.0.0.1 is absent from the above config).

firewalld

sudo firewall-cmd --zone=public --add-forward-port=port=80:proto=tcp:toport=8010   
sudo firewall-cmd --runtime-to-permanent

This is a single-purpose set-up, so I don't need to worry much about running a webserver or anything else.

dkarnout commented 2 years ago

Thanks for your idea 👍 , just implemented it with iptables (only for my LAN, because I have external http requests): sudo iptables -t nat -A PREROUTING -s 192.168.1.1/24 -p tcp --dport 80 -j REDIRECT --to-port 8010 Everything works ok from my home LAN devices, except from my NA7004 😞 which asks me to visit radiomarantz.com... So I believe that it looks directly into an IP and not into a domain. Any other device from my LAN is redirected correctly to myhomeserver/ycast from:

radiomarantz.com
*.vtuner.com

Someday I may try to sniff NA7004's requests and keep up inform any interested.

SpeedyGoneZales commented 2 years ago

@dkarnout, I'm glad it helped you. An http server is of course a much better solution, but I have only a single device, so I guess for that use case it's ok.

I don't have an NA7004, but I'd be surprised if it's a different logic to mine (MCR610); is the DNS server set correctly on your NA7004? I'm only redirecting *.vtuner.com and vtuner.com, which I'm doing directly on my router, and the MCR610 receives the router's IP address as DNS server via DHCP. The former should cover denon.vtuner.com, which I believe is what Marantz uses. My MCR610 does occasionally lose network connectivity completely, I am only able to restore it by resetting it completely in this case (unplug the power, and hold the <M-DAX> and <DISPLAY> buttons while plugging it back in). This means losing all settings unfortunately...

dkarnout commented 2 years ago

@SpeedyGoneZales I managed it with your help (again)! The problem was NA7004's DNS setting as you said. While had already put my router IP (192.168.1.1) at: Menu -> Network -> Connection -> Primary DNS, the value does not store until you follow after that Menu -> Network -> Connection -> Connection, and that was my problem.

So I can confirm yCast works flawlessly for NA7004 with mandatory both local DNS records: denon.vtuner.com and denon2.vtuner.com. Thank you again and do have nice holidays!