大网数据广告活动
服务器运维问答

Access container from subdomain using https on apache

· 52CE 我爱测

basically I have a docker container exposed on port 8080 and it already has his SSL certificate. I want to access that container using a subdomain without modifying the url and using that container certificate. The main domain al…

问题原文

原帖链接 · Tito Tigi · CC BY-SA 4.0

basically I have a docker container exposed on port 8080 and it already has his SSL certificate. I want to access that container using a subdomain without modifying the url and using that container certificate. The main domain already has his own certificate but I would like to use the docker container one. In otherwords, I would like users to use subdomain.example.com to access example.com:8080 using https but without letting them know of that redirect. I configured the virtual host like that:

<VirtualHost subdomain.example.com:443>
        ServerAdmin [email omitted]
        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>

but I get an ERR_SSL_PROTOCOL_ERROR. Do you have any suggestion on how I could implement it?

已采纳解答

原帖链接 · Tito Tigi · CC BY-SA 4.0

The reason why it wasn't working is because I needed to create an SSL certificate for the subdomain (I used certbot to make it). The final configuration looks like this:

<VirtualHost subdomain.example.com:443>
        ServerAdmin [email omitted]
        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>

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-05-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。