I have a single Apache 2.0 httpd instance that I'd like to host both HTTP and HTTPS. They share the same IP address and HTTP would come on port 80 and HTTPS on port 443 (standard). I have 2 domains www.example.com and secure.example.com that both point to that IP address.
Now the problem: I want only HTTP traffic to www.example.com and only HTTPS traffic to secure.example.com. This means no HTTPS to www.example.com and no HTTP to secure.example.com.
My httpd.conf looks like
ServerName www.example.com
Listen 10.0.0.1:80
Listen 10.0.0.1:443
NameVirtualHost 10.0.0.1:80
NameVirtualHost 10.0.0.1:443
<VirtualHost 10.0.0.1:80>
ServerName www.example.com
</VirtualHost>
<VirtualHost 10.0.0.1:443>
ServerName secure.example.com
SSLEnable # ... and other SSL stuff
</VirtualHost>
What's happening now is that I can get to both domain names using both HTTP and HTTPS. I looked up port-based virtual hosting and name-based virtual hosting and it seems that what I have should work. I'm not trying to host multiple domains in SSL, so no problem there. I just want the user to be denied going to www.example.com using HTTPS and vice versa for secure.example.com.
Is this even possible without a separate IP alias?