| Line 2: |
Line 2: |
| | Paths:<br /> | | Paths:<br /> |
| | /etc/apache2/sites-available<br /> | | /etc/apache2/sites-available<br /> |
| − | /etc/apache2/sites-enabled (symbolic links to sites-available/*.conf files)<br /> | + | /etc/apache2/sites-enabled (symbolic links to sites-available/*.conf files)<br /><syntaxhighlight lang="bash"> |
| | + | sudo apache2ctl -t -D DUMP_VHOSTS |
| | + | sudo apache2ctl configtest |
| | + | sudo a2enmod ssl |
| | + | </syntaxhighlight> |
| | | | |
| | ==Virtual Hosts== | | ==Virtual Hosts== |
| Line 28: |
Line 32: |
| | to the public ip of this server<br /> | | to the public ip of this server<br /> |
| | | | |
| − | Basic SSL VirtualHost: | + | Basic SSL VirtualHost:<syntaxhighlight lang="apache"> |
| − | <nowiki><VirtualHost *:80>
| + | <VirtualHost *:80> |
| − | ServerName home.rra.lan
| + | ServerName home.rra.lan |
| − | ServerAdmin webmaster@rra.lan
| + | ServerAdmin webmaster@rra.lan |
| − | DocumentRoot /var/www/home.rra.lan
| + | DocumentRoot /var/www/home.rra.lan |
| − |
| + | Redirect permanent / https://home.rra.lan |
| − | Redirect permanent / https://home.rra.lan
| + | ErrorLog ${APACHE_LOG_DIR}/error.log |
| − | ErrorLog ${APACHE_LOG_DIR}/error.log
| + | CustomLog ${APACHE_LOG_DIR}/access.log combined |
| − | CustomLog ${APACHE_LOG_DIR}/access.log combined
| + | </VirtualHost> |
| − | </VirtualHost>
| + | <VirtualHost *:443> |
| − | <VirtualHost *:443>
| + | ServerName home.rra.lan |
| − | ServerName home.rra.lan
| + | ServerAdmin webmaster@rra.lan |
| − | ServerAdmin webmaster@rra.lan
| + | DocumentRoot /var/www/home.rra.lan |
| − | DocumentRoot /var/www/home.rra.lan
| + | ErrorLog ${APACHE_LOG_DIR}/error.log |
| − | ErrorLog ${APACHE_LOG_DIR}/error.log
| + | CustomLog ${APACHE_LOG_DIR}/access.log combined |
| − | CustomLog ${APACHE_LOG_DIR}/access.log combined
| + | SSLEngine on |
| − |
| + | SSLCertificateKeyFile /etc/ssl/private/home.rra.lan.key |
| − | SSLEngine on
| + | SSLCertificateFile /etc/ssl/certs/home.rra.lan.crt |
| − | SSLCertificateKeyFile /etc/ssl/private/home.rra.lan.key
| + | SSLCertificateChainFile /etc/ssl/certs/FreeIPA-CA.crt |
| − | SSLCertificateFile /etc/ssl/certs/home.rra.lan.crt
| + | </VirtualHost> |
| − | SSLCertificateChainFile /etc/ssl/certs/FreeIPA-CA.crt
| + | </syntaxhighlight> |
| − | </VirtualHost>
| + | |
| − | </nowiki>
| |
| | | | |
| | ==Redirect HTTP to HTTPS== | | ==Redirect HTTP to HTTPS== |
| − | sudo nano /etc/apache2/sites-available/redirect_HTTP_to_HTTPS.conf | + | <code>sudo a2enmod rewrite</code> |
| − | <nowiki><VirtualHost *:80>
| + | |
| − | RewriteEngine on
| + | <code>sudo nano /etc/apache2/sites-available/redirect_HTTP_to_HTTPS.conf</code> |
| − | RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
| + | |
| − | </VirtualHost></nowiki>
| + | <syntaxhighlight lang="apache"> |
| − | sudo ln -s /etc/apache2/sites-available/redirect_HTTP_to_HTTPS.conf /etc/apache2/sites-enable/redirect_HTTP_to_HTTPS | + | <VirtualHost *:80> |
| | + | RewriteEngine on |
| | + | RewriteCond %{HTTPS} !=on |
| | + | RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] |
| | + | |
| | + | ErrorLog ${APACHE_LOG_DIR}/error.log |
| | + | CustomLog ${APACHE_LOG_DIR}/access.log combined |
| | + | </VirtualHost> |
| | + | </syntaxhighlight> |
| | + | |
| | + | <code>sudo ln -s /etc/apache2/sites-available/redirect_HTTP_to_HTTPS.conf /etc/apache2/sites-enable/redirect_HTTP_to_HTTPS.conf</code> |
| | + | |
| | ==Authentication== | | ==Authentication== |
| | | | |
| Line 66: |
Line 80: |
| | Protect with the directory directive: | | Protect with the directory directive: |
| | <nowiki><Directory "/usr/local/apache/htdocs/secret"> | | <nowiki><Directory "/usr/local/apache/htdocs/secret"> |
| − | AuthType Basic
| + | AuthType Basic |
| − | AuthName "Restricted Files"
| + | AuthName "Restricted Files" |
| − | # (Following line optional)
| + | # (Following line optional) |
| − | AuthBasicProvider file
| + | AuthBasicProvider file |
| − | AuthUserFile "/usr/local/apache/passwd/passwords"
| + | AuthUserFile "/usr/local/apache/passwd/passwords" |
| − | # Require user rbowen
| + | # Require user rbowen |
| − | Require valid-user
| + | Require valid-user |
| − | </Directory></nowiki>
| + | </Directory></nowiki> |
| | | | |
| | ==Reverse Proxy== | | ==Reverse Proxy== |
| Line 119: |
Line 133: |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |
| − | == apachectl == | + | ==apachectl== |
| | <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
| | sudo apachectl configtest | | sudo apachectl configtest |