====== Apache mit SSL ====== Konfigurationen für SSL-Einsatz mit Apache! Vorhergehend sollte man natürlich ein [[ssl-key|SSL-Key]] erstellt haben. ===== 1. Ports-Datei einrichten ===== NameVirtualHost *:80 Listen 80 NameVirtualHost *:443 Listen 443 ===== 2. Default-Datei editieren ===== NameVirtualHost IP01:80 NameVirtualHost IP01:443 NameVirtualHost IP02:80 NameVirtualHost IP03:80 ServerAdmin webmaster@localhost DocumentRoot /var/www Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all 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 SSLEngine On SSLCertificateFile /etc/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.key ServerAdmin webmaster@localhost DocumentRoot /var/www Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all SSLRequireSSL ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all 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 ===== 3. VHost-Editieren ===== Dann den Virtual-Host-Eintrag editieren und für Port 80 und für Port 443 (ssl) einrichten. DocumentRoot "/srv/virtual-host/webroot" ServerName virtual-host.de allow from all AllowOverride FileInfo Limit Options 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" SSLEngine On SSLCertificateFile /etc/apache2/ssl/virtual-host.crt SSLCertificateKeyFile /etc/apache2/ssl/virtual-host.key DocumentRoot "/srv/virtual-host/webroot" ServerName virtual-host allow from all AllowOverride FileInfo Limit Options 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" ===== 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: ServerName apache2-redirect.railshoster.de Redirect 301 / https://apache2-redirect.railshoster.de/ 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. {{tag>linux unix}}