Benutzer-Werkzeuge

Webseiten-Werkzeuge


apache_mit_ssl

Apache mit SSL

Konfigurationen für SSL-Einsatz mit Apache!
Vorhergehend sollte man natürlich ein SSL-Key erstellt haben.

1. Ports-Datei einrichten

ports.conf
    NameVirtualHost *:80 
    Listen 80 
 
    <IfModule mod_ssl.c> 
        NameVirtualHost *:443 
        Listen 443 
    </IfModule> 

2. Default-Datei editieren

default
NameVirtualHost IP01:80 
NameVirtualHost IP01:443 
NameVirtualHost IP02:80 
NameVirtualHost IP03:80 
<VirtualHost _default_:80> 
        ServerAdmin webmaster@localhost 
 
        DocumentRoot /var/www 
        <Directory /> 
                Options FollowSymLinks 
                AllowOverride None 
        </Directory> 
        <Directory /var/www/> 
                Options Indexes FollowSymLinks MultiViews 
                AllowOverride None 
                Order allow,deny 
                allow from all 
        </Directory> 
 
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
        <Directory "/usr/lib/cgi-bin"> 
                AllowOverride None 
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
                Order allow,deny 
                Allow from all 
        </Directory> 
 
        ErrorLog ${APACHE_LOG_DIR}/error.log 
 
        # Possible values include: debug, info, notice, warn, error, crit, 
        # alert, emerg. 
        LogLevel warn 
 
        CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost> 
 
<VirtualHost _default_:443> 
        SSLEngine On 
        SSLCertificateFile /etc/apache2/ssl/apache.crt 
        SSLCertificateKeyFile /etc/apache2/ssl/apache.key 
        ServerAdmin webmaster@localhost 
 
        DocumentRoot /var/www 
        <Directory /> 
                Options FollowSymLinks 
                AllowOverride None 
        </Directory> 
        <Directory /var/www/> 
                Options Indexes FollowSymLinks MultiViews 
                AllowOverride None 
                Order allow,deny 
                allow from all 
                SSLRequireSSL 
        </Directory> 
 
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
        <Directory "/usr/lib/cgi-bin"> 
                AllowOverride None 
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
                Order allow,deny 
                Allow from all 
        </Directory> 
 
        ErrorLog ${APACHE_LOG_DIR}/error.log 
 
        # Possible values include: debug, info, notice, warn, error, crit, 
        # alert, emerg. 
        LogLevel warn 
 
        CustomLog ${APACHE_LOG_DIR}/access.log combined 
 
</VirtualHost>

3. VHost-Editieren

Dann den Virtual-Host-Eintrag editieren und für Port 80 und für Port 443 (ssl) einrichten.

virtual-host.conf
<VirtualHost virtual-host.de:80> 
DocumentRoot "/srv/virtual-host/webroot" 
ServerName virtual-host.de 
<Directory "/srv/virtual-host/webroot"> 
allow from all 
AllowOverride FileInfo Limit Options 
</Directory> 
ServerAdmin webmaster@virtual-host 
ServerAlias www.virtual-host 
ErrorLog /srv/virtual-host/logs/error.log 
LogLevel alert 
LogFormat "combined" 
CustomLog /srv/virtual-host/logs/access.log "combined" 
</VirtualHost> 
 
<VirtualHost virtual-host:443> 
        SSLEngine On 
        SSLCertificateFile /etc/apache2/ssl/virtual-host.crt 
        SSLCertificateKeyFile /etc/apache2/ssl/virtual-host.key 
DocumentRoot "/srv/virtual-host/webroot" 
ServerName virtual-host 
<Directory "/srv/virtual-host/webroot"> 
allow from all 
AllowOverride FileInfo Limit Options 
</Directory> 
ServerAdmin webmaster@virtual-host 
ServerAlias www.virtual-host 
ErrorLog /srv/marcel-web/net-addicts.de/logs/error.log 
LogLevel alert 
LogFormat "combined" 
CustomLog /srv/virtual-host/logs/access.log "combined" 
</VirtualHost> 

4. Automatisch auf https umswitchen

Oft möchte man eine Seite durch den Apache HTTP Server nicht per HTTP, sondern lieber per SSL verschlüsseltem HTTPS zugreifbar machen. Gerade wenn vorher schon Links auf die HTTP-URL gesetzt wurden, ist es wünschenswert die bisherige URL weiterhin erreichbar zu lassen, dann aber mit einer Weiterleitung (Redirect) zur SSL verschlüsselten Version der Webseite.

Davon ausgehend, dass ein SSL-Zertifikat (SSL-Certificate) bereits entweder selbst signiert (self-signed) bzw. gekauft und eingerichtet wurde, läßt sich der Redirect wie folgt einrichten:

virtual-host.conf
<VirtualHost virtualhost:80> 
 
 ServerName apache2-redirect.railshoster.de 
 
<Location /> 
  Redirect 301 / https://apache2-redirect.railshoster.de/ 
</Location> 
 
</VirtualHost>

In diesem Fall wird ein virtueller Host definiert, der auf die imaginäre URL apache2-redirect.railshoster.de reagiert und Anfragen an die mittels Apache mod_ssl gesicherte URL https://apache2-redirect.railshoster.de weiterleitet.

apache_mit_ssl.txt · Zuletzt geändert: 07.10.2013 19:43 (Externe Bearbeitung)