Access container from subdomain using https on apache
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 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>
but I get an ERR_SSL_PROTOCOL_ERROR. Do you have any suggestion on how I could implement it?
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 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>