[Apache2] HTTPS en HTTP op 1 IP

Pagina: 1
Acties:
  • 463 views sinds 30-01-2008
  • Reageer

  • Mathijs1
  • Registratie: Oktober 2002
  • Niet online
Ik probeer nu al de hele avond het voor elkaar te krijgen dat http://url en https://url allebei op 1 Apache installatie werken, maar ik krijg het maar niet werkend.

Relevante info uit apache2.conf:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Listen 80
Listen 443
...
NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
...
    DocumentRoot "/var/www/http"
</VirtualHost>

<VirtualHost *:443>
...
    DocumentRoot "/var/www/https"
    <IfModule mod_ssl.c>
...
        SSLEngine on
    </IfModule>
</VirtualHost>


Hier dus met Virtualhosts, ik wilde het eerst per Directory maar dat schijnt al helemaal niet te werken. Als ik de server nu via :80 bekijk werkt het prima, en als ik het hele VirtualHosts verhaal niet gebruik en de hele server onder HTTPS draai werkt het ook.

Ik heb gelezen dat SSL niet werkt met NameVirtualHosts, maar alleen met IP-based virtual hosts. Dit lijkt me een beetje krom, je zit al op poort 443 te praten met de server en dan zou je ineens geen virtualhost kunnen gebruiken?

In ssl_error.log komt verder niets nieuws te staan met bovenstaande config, bij het openen van de pagina.

[ Voor 5% gewijzigd door Mathijs1 op 14-11-2007 03:48 ]


  • TokkeF
  • Registratie: Januari 2005
  • Laatst online: 08:14
Het gaat inderdaad niet gaat.

In de documentatie staat het duidelijke uitgelegd waarom het niet gaat :
Name-Based Virtual Hosting is a very popular method of identifying different virtual hosts. It allows you to use the same IP address and the same port number for many different sites. When people move on to SSL, it seems natural to assume that the same method can be used to have lots of different SSL virtual hosts on the same server.

It comes as rather a shock to learn that it is impossible.

The reason is that the SSL protocol is a separate layer which encapsulates the HTTP protocol. So the SSL session is a separate transaction, that takes place before the HTTP session has begun. The server receives an SSL request on IP address X and port Y (usually 443). Since the SSL request does not contain any Host: field, the server has no way to decide which SSL virtual host to use. Usually, it will just use the first one it finds, which matches the port and IP address specified.

You can, of course, use Name-Based Virtual Hosting to identify many non-SSL virtual hosts (all on port 80, for example) and then have a single SSL virtual host (on port 443). But if you do this, you must make sure to put the non-SSL port number on the NameVirtualHost directive, e.g.

NameVirtualHost 192.168.1.1:80

Other workaround solutions include:

Using separate IP addresses for different SSL hosts. Using different port numbers for different SSL hosts.

  • Mathijs1
  • Registratie: Oktober 2002
  • Niet online
In die quote staat dat je niet meerdere SSL virtual hosts kunt hebben op 1 server, dat wil ik ook niet. Wat ik wel wil is non-SSL en een single SSL (in de quote staat dat dit wel mogelijk is). Het non-SSL port number zit ook in het NameVirtualHost directive, dus dat zou moeten kunnen..