要在Apache上使用子域名/路由来暴露SSL上的Web应用程序的端口,您需要进行以下步骤:
apachectl -M | grep ssl
如果输出中包含“ssl_module”字样,则表示已正确安装了SSL模块。
sudo nano /etc/apache2/sites-available/000-default.conf
ServerName subdomain.example.com
Redirect permanent / https://subdomain.example.com/
ServerName subdomain.example.com
SSLEngine on
SSLCertificateFile /path/to/certificate.crt
SSLCertificateKeyFile /path/to/private.key
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
在上述示例中,我们使用了两个虚拟主机定义:一个用于HTTP(端口80),另一个用于HTTPS(端口443)。您需要将“subdomain.example.com”替换为您实际的子域名。
sudo a2ensite 000-default.conf
sudo service apache2 restart
现在,您的Apache服务器应该已经通过子域名/路由暴露了SSL上的Web应用程序的端口。在上述示例中,所有来自“https://subdomain.example.com”的请求都将被代理到本地的8080端口,您可以相应地配置您的Web应用程序以侦听该端口。