2

I have a local Apache2 server which hosts two name-based websites on a single IP.

The first website is hosted only on port 80. The second is hosted on port 80 and 443. If accessed on port 80 the user is redirected to port 443.

one.local (HTTP only):

<VirtualHost *:80>

    ServerName one.local
    ServerAlias www.one.local
    DocumentRoot /var/www/html/one

</VirtualHost>

two.local (http and https):

<VirtualHost *:80>

    DocumentRoot /var/www/html/two

    ServerName two.local
    ServerAlias www.two.local

    Redirect permanent / https://two.local  

</VirtualHost>

<VirtualHost *:443>

    DocumentRoot /var/www/html/two

    ServerName two.local
    ServerAlias www.two.local

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/apache.pem
    SSLCertificateKeyFile /etc/apache2/ssl/apache.key

</VirtualHost>

Both websites are accessible, using the domain name and two.local gets redirected just fine.

The issue I have, is that when accessing https://one.local, the user is connected and prompted the Your connection is not secure warning as the self-signed certificate of two.local is attempted to be used.

I've read about this issue in this question, where it seems that the solution is to use the same certificate again and redirect from https to http.

This question has been asked three years ago, is there a better solution to this issue?

  • 2
    With the advent of completely free (as in beer) well supported TLS certificates via letsencrypt there is no reason to not support HTTPS/TLS for all your sites... – HBruijn Jul 22 '16 at 16:45
  • I understand and completely agree, however, this is for a local project which requires plain HTTP. – boolean.is.null Jul 22 '16 at 16:57
  • You need two IP addresses. We've had this question asked a few times before. But of course, the proper solution is HTTPS for both sites. – Michael Hampton Jul 22 '16 at 17:11
  • When it is local you should have no problems to use a second IP address. I, too, don't see another option. – Phillip -Zyan K Lee- Stockmann Jul 22 '16 at 19:40
  • Alright. So if there's no other option, can someone post an answer and I'll accept it. Thank you for your help. – boolean.is.null Jul 22 '16 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.