简体   繁体   中英

Apache httpd.conf for redirecting ip to hostname - SSL

In a similar problem addressed here (Apache httpd.conf for redirecting ip to hostname)
I would like to know how to do a redirect from an HTTPS over SSL static ip to hostname.

I am currently using the configuration posted below but when I test it I get the warning and I actually have to click "Proceed to site" before it redirects. I tried removing the SSLEngine on segment but then it will not connect outright.

Listen 443

<VirtualHost *:443>
        ServerName 192.168.1.1 #Not the actual IP of server
        ServerAlias 192.168.1.1 #Not the actual IP of server

        SSLEngine on
        SSLCertificateFile /var/ssl/website/cert.crt
        SSLCertificateKeyFile /var/ssl/website/privkey.key

        RewriteEngine On
        RewriteCond %{HTTP_HOST} !^website.com$
        RewriteRule /.* https://website.com/ [R]
</VirtualHost>

Any idea on what needs to be done to avoid having to click "Proceed to site" to allow it to redirect?

To redirect from some https site to anything else you need to have a valid certificate for this site, ie a certificate where the subject matches the name in the URL. In your case the certificate probably does not include the IP address and that's why the access to the site will result in a certificate validation error which you've explicitly ignored by clicking "Proceed to site".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM