基本上,我在端口 8080 上公开了一个 docker 容器,并且它已经有了 SSL 证书。我想使用子域访问该容器,而无需修改 URL 并使用该容器证书。主域已经有自己的证书,但我想使用 docker 容器证书。换句话说,我希望用户使用 subdomain.example.com 通过 https 访问 example.com:8080,但不让他们知道该重定向。我像这样配置了虚拟主机:
<VirtualHost subdomain.example.com:443>
ServerAdmin [email protected]
ServerName subdomain.example.com
ServerAlias subdomain.example.com
ProxyRequests Off
#ProxyPass / http://localhost:8080/
<Location />
ProxyPreserveHost On
ProxyPass https://example.com:8080/
ProxyPassReverse https:/example.com:8080/
</Location>
# Uncomment the line below if your site uses SSL.
SSLProxyEngine On
</VirtualHost>
但我收到 ERR_SSL_PROTOCOL_ERROR。您对我该如何实现它有什么建议吗?
答案1
它不起作用的原因是因为我需要为子域创建 SSL 证书(我使用 certbot 来创建)。最终配置如下:
<VirtualHost subdomain.example.com:443>
ServerAdmin [email protected]
ServerName subdomain.example.com
ServerAlias subdomain.example.com
ProxyRequests Off
#ProxyPass / http://localhost:8080/
<Location />
ProxyPreserveHost On
ProxyPass https://example.com:8080/
ProxyPassReverse https://example.com:8080/
</Location>
# Uncomment the line below if your site uses SSL.
SSLProxyEngine On
SSLCertificateFile /etc/letsencrypt/live/subdomain.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/subdomain.example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>