使用 Let's Encrypt 为 Icecast2 添加 HTTPS 支持



我有一台Icecast2服务器在默认端口8000上运行,我想用免费的Let's Encrypt证书为其添加HTTPs支持。例如:

  • http://example.com:8000/test.mp3(电流(
  • https://example.com/test.mp3(需要(

我已经看到Icecast2在内部支持SSL,但该选项在一些(大多数?(GNU/Linux发行版中不可用。此外,我发现使用内部SSL支持与Let's Encrypt并没有很好的集成,因为您必须将两个证书连接到一个文件中。

https://icecast.org/docs/icecast-2.4.1/config-file.html

https://community.letsencrypt.org/t/icecast2-and-letsencrypt/9329

问题:使用Let's Encrypt向Icecast2添加https://支持的建议方法是什么?

例如,使用Debian GNU/Linux稳定版的官方icecast2包,而不编译任何内容。请注意,在服务器上,我已经运行了Web服务器Apache HTTPd(apache2(,侦听端口80443。非常感谢。

您的icecast2包中是否支持本机SSL

如果你喜欢使用官方软件包,请首先检查你已经安装的icecast2软件包是否支持SSL:

ldd /usr/bin/icecast2 | grep ssl

如果您没有看到任何内容,则说明您对SSL没有本机支持。在这种情况下,您可以选择以下选项之一:

  • A:删除程序包并安装其他程序
  • B:使用nginx设置前端Web服务器
  • C:使用Apache设置前端Web服务器(←这个答案(

如何使用Apache设置支持HTTPs的前端Web服务器,并为Icecast2提供服务

如果您想为Icecast提供https://支持,可以安装Apache并将其用作前端Web服务器,在标准端口443上侦听。使用Let's Encrypt创建免费证书很容易。一旦它起作用,你就可以将交通转移到Icecast2。

如果你使用Debian GNU/Linux,这里的指南:

  • https://wiki.debian.org/Icecast2

解决方案的核心是启用这样的apacheVirtualHost:

#
# Apache VirtualHost serving my Icecast under HTTPs (:443)
#
# This frontend webserver passes all the traffic to
# the underlying Icecast, listening on port 8000.
#
# The certificate comes from Let's Encrypt.
#
# Credits: https://stackoverflow.com/a/71383133/3451846
<virtualhost *:443>
ServerName example.com
# this path is not useful and it's used only for Let's Encrypt's temporary files during the renewal process
DocumentRoot /var/www/html
# send all traffic to Icecast in plaintext
<Location "/">
ProxyPass        http://localhost:8000/
ProxyPassReverse http://localhost:8000/
</Location>
# these files are served from /var/www/html to serve Let's Encrypt temporary files
<Location "/.well-known/acme-challenge">
ProxyPass !
</Location>
<IfFile /etc/letsencrypt/live/example.com/cert.pem>
SSLEngine on
SSLCertificateFile      /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile   /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
</IfFile>
</virtualhost>
<VirtualHost *:80>
ServerName example.com
Redirect / https://example.com/
</VirtualHost>

然后启用它并颁发证书:

letsencrypt certonly --domain example.com --webroot --webroot-path /var/www/html

但从上面的指南中可以更好地解释这一点。

目前,该指南没有涵盖nginx,但其他答案可能会给出使用该技术以及apache2的类似实践示例。使用像apache2nginx这样的前端Web服务器的好处是您不必接触Icecast。此外,它还允许在您现有的网站中为Icecast2提供服务(如果有的话(。


其他答案可能想谈谈Icecast2与Let's Encrypt的本地接口。目前,我只能分享apache2方法,这是我多年来在生产中使用的方法,没有任何问题。此外,由于我使用Debian GNU/Linux,我的软件包不支持SSL。

最新更新