I would like to redirect a virtual host on my server to another domain, which is running on HTTPS. I also would like to only show the original url, hence using the P flag for proxy. Here is the current configuration :
RewriteEngine on
SSLProxyEngine on
RewriteCond %{HTTP_HOST} ^subdomain1.domain1.ext1$ [NC]
RewriteRule ^(.*) https://subdomain2.domain2.ext2$1 [L,R,P]
Should I generate a certificate on domain1 with certbot? What webroot should I associate? Should I include the one from domain2?
Currently, I have this in the error.log:
[Wed Jun 27 09:13:42.011549 2018] [ssl:error] [pid 19805] [remote IP2:443] AH01961: SSL Proxy requested for domain1.ext1:80 but not enabled [Hint: SSLProxyEngine]
[Wed Jun 27 09:13:42.011734 2018] [proxy:error] [pid 19805] AH00961: HTTPS: failed to enable ssl support for IP2:443 (subdomain2.domain2.ext2)
However SSLProxyEngine
is set.
2
Answers
Finally, the best solution was to use mod_proxy instead of mod-rewrite.
The http version (redirecting to https)
The https version
since you did not show your VirtualHost setup, here is how I would do it from scratch.
First setup a VirtualHost for port 443 on your first Apache server:
Then setup another VirtualHost for domain2, again on port 443, on another server:
http://www.domain1.com
this will sent to the matching VirtualHost on port 80, which is HTTP, hence no SSL. You should ask forhttps://www.domain1.com
.If you want to put both on 1 system, you will have a slight problem. You cannot have two VirtualHost with different domain names on the same IP and same port (443) for SSL. This is because Apache does not know which domain you want until after the certificates are negotiate. So the way to solve this is:
Listen IP1:443
andListen IP2:443
and setup your VirtualHost using these as well.https://subdomain2.domain2.ext2:<THE PORT>/$1
But this is a long subject and you would need to do some research into running many HTTPS sites on the same server for all the details.