https / http virtual host problem

Hi openSUSE users!

I have problems when it comes down to https / http virtual hosts … If I have in my /etc/apache2/vhosts/www.example.com.conf

<VirtualHost *>
DocumentRoot “/srv/www/htdocs/example.com”
ServerName Example Web Page
<Directory “/srv/www/htdocs/example.com”>
allow from all
Options +Indexes
</Directory>
</VirtualHost>

HTTP:// WORKS …

If I have

<VirtualHost *>
DocumentRoot “/srv/www/htdocs/example.com”
ServerName Example Web Page
<Directory “/srv/www/htdocs/example.com”>
allow from all
Options +Indexes
</Directory>
SSLEngine on
SSLCertificateFile /etc/apache2/secure/ssl/certs/123.pem
SSLCertificateKeyFile /etc/apache2/secure/ssl/private/123.pem

</VirtualHost>

HTTPS:// WORKS …

**IF HTTPS WORKS HTTP FAILS …
IF HTTP WORKS HTTPS FAILS …
**

Is it possible to enable HTTP and HTTPS ? …

Did you remember to enable port 443 in listen.conf? And that should be <Virtualhost *:443> for https so that <Virtualhost *:80> can be a separate http host.

Also you have to realise that you can’t have more than one https virtual host per IP address. If you try to have more then one, they all map to the same domain. The reason is that https is negotiated before the Host: line is seen. So the verification is based on the IP address and domain name of the host, not any virtual hostname.

Thanks for quick reply ken_yap …
If I enable port 443 in listen.conf I get after apache refresh …

Syntax OK
Shutting down httpd2 (waiting for all children to terminate) …done
Starting httpd2 (prefork) (98)Address already in use: make_sock: could not bind to address ::]:443
…failed

Still works just HTTPS or HTTP not both … ?

You didn’t read the second sentence of my reply. You have to change the places where you currently have <Virtualhost *> to <Virtualhost *:80> to prevent those from binding to port 443, only to port 80. Your https host will have <Virtualhost *:443>.

If you look in /etc/apache2/vhosts.d/vhost-ssl.template, there is an example for you. Since there can only be one https host per IP, they have used <Virtualhost default:443>

Sorry since I don’t understand …

Can you be more specific please …

When I copy content from vhost-ssl.template to www.example.com.conf still fails to work …

Can someone please help out with above problem …

It’s not sufficient to just copy it, you have to modify it to suit your needs after copying. It is after all, a template.

Hello ken_yap

This is what I’m getting after apache2 restart …

[error] VirtualHost default:443 – mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
Syntax OK
Shutting down httpd2 (waiting for all children to terminate) …done
Starting httpd2 (prefork) [Tue Jan 06 13:18:38 2009] [error] VirtualHost default:443 – mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
…done

Let me be brutally blunt here: Do you have some reading material or documentation to follow that explains what all those Apache directives mean, or are you just changing a bit here and there without any understanding, in the hope that something will work?

Because if random changes here and there don’t solve your problem maybe you should consider a better strategy.

Hello …

Random changes here and there solved my problem :wink:
There is no need to copy all those files in etc/apache2/vhosts … and rename them … and do modifications in listen.conf … and bunch of other stuff …
I have managed to do all tricks within couple of minutes … so now it works HTTPS and HTTP together with mod_rewrite (pretty url) on both ports … etc.
:slight_smile:

Can you post how you did this maybe usefull to others

/Geoff