Dodawanie nowej domeny – katalog, konfiguracja Apache2, certbot
Kategoria: Apache
HTTP – Authentication
Rodzaje: Basic, Digest, Bearer (OAuth 2.0), HOBA (HTTP Origin-Bound Authentication), Mutual, AWS4-HMAC-SHA256
Apache2 – http header – Server
Usunięcie z nagłówków HTTP nazwy serwera Apache 2
/etc/apache2/apache2.conf
ServerSignature Off ServerTokens Prod
Apache2 – cache’owanie
.htaccess – mapowanie adresów
# Wymuszanie https:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Virtual host + certyfikat + SSL
Utworzenie wirtualnego hosta /etc/apache2/sites-available/000-default.conf
<VirtualHost 81.137.4.24:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html/example ServerName example.pl </VirtualHost>
Przedłużenie sesji PHP
.htaccess – 14 dni czas sesji
php_value session.gc_maxlifetime 1209600
Apache SSL
# cd /etc/apache2 # a2enmod ssl # a2ensite default-ssl # systemctl reload apache2 # mkdir /etc/apache2/ssl # openssl req -x509 -nodes -days 1825 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt # chmod 600 /etc/apache2/ssl/* # nano /etc/apache2/sites-enabled/default-ssl.conf
default-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
ServerName bambino.pl:443
DocumentRoot /var/www/html/bambino/webroot
. . .
SSLEngine on
. . .
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
# service apache2 reload # openssl s_client -connect intranet.int:443
mod_rewrite
Włączenie modułu mod_rewrite
# a2enmod rewrite # systemctl restart apache2
# editor /etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Lub
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
. . .
</VirtualHost>
Apache – cmd
how-to-create-a-ssl-certificate-on-apache-for-debian-8
Lista modułów, włączenie, wyłączenie
# a2enmod ssl # a2dismod ssl
Restart serwera
# service apache2 restart # systemctl restart apache2 # /etc/init.d/apache2 restart
Apache – włączenie ssl
Zakładając istnienie openSSL
# apt-get upgrade openssl
# a2enmod ssl ----------------- Considering dependency setenvif for ssl: Module setenvif already enabled Considering dependency mime for ssl: Module mime already enabled Considering dependency socache_shmcb for ssl: Enabling module socache_shmcb. Enabling module ssl. See /usr/share/doc/apache2/README.Debian.gz on how to configure SSL and create self-signed certificates. To activate the new configuration, you need to run: systemctl restart apache2
# a2ensite default-ssl ----------------- Enabling site default-ssl. To activate the new configuration, you need to run: systemctl reload apache2
# service apache2 reload
Wymuszenie https://
Plik .htaccess
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]