Aș dori să lucrez cu configurația apache2 http://openproject.example.com și https://example.com (blog wordpress).
Configurația mea:
/etc/apache2/sites-enabled/wordpress.conf
<VirtualHost *:80>
ServerAdmin admin@HOSTNAME_HERE.com
DocumentRoot /var/www/HOSTNAME_HERE/wordpress/
Redirect / https://HOSTNAME_HERE.com/
<Directory /var/www/HOSTNAME_HERE/wordpress/>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/apache2/conf-enabled/wordpress.conf
Alias /wordpress /var/www/HOSTNAME_HERE/wordpress
<Director /var/www/HOSTNAME_HERE/wordpress>
Opțiuni FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php.c>
<IfModule mod_mime.c>
Aplicația AddType/x-httpd-php .php
</IfModule>
<FilesMatch ".+\.php$">
Aplicația SetHandler/x-httpd-php
</FilesMatch>
</IfModule>
</Director>
<Director /usr/share/phpmyadmin/setup>
<IfModule mod_authz_core.c>
<IfModule mod_authn_file.c>
AuthType Basic
</IfModule>
Necesită utilizator valid
</IfModule>
</Director>
<Director /usr/share/phpmyadmin/libraries>
Solicitați refuzul tuturor
</Director>
<Director /usr/share/phpmyadmin/setup/lib>
Solicitați refuzul tuturor
</Director>
disponibil cu SSL prin
/etc/apache2/sites-enabled/default-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin admin@HOSTNAME_HERE.com
ServerName ip.address.of.hostname
DocumentRoot /var/www/HOSTNAME_HERE/wordpress/
<Directory /var/www/HOSTNAME_HERE/wordpress/>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384...
SSLHonorCipherOrder on
SSLCompression off
SSLSessionTickets off
SSLCertificateFile /etc/apache2/ssl/certificate.crt
SSLCertificateKeyFile /etc/apache2/ssl/pkey.key
SSLCertificateChainFile /etc/apache2/ssl/chain-ca.crt
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
/etc/apache2/sites-enabled/openproject.conf
<VirtualHost *:80>
ServerName openproject.example.com
DocumentRoot /opt/openproject/public
ProxyRequests off
Include /etc/openproject/addons/apache2/includes/vhost/*.conf
# Can't use Location block since it would overshadow all the other proxypass directives on CentOS
ProxyPass / http://127.0.0.1:6000/ retry=0
ProxyPassReverse / http://127.0.0.1:6000/
</VirtualHost>
/etc/openproject/addons/apache2/includes/vhost/openproject.conf
ServerName openproject.example.com
redirecționare permanentă / http://example.com/
ServerName openproject.example.com
ServerAdmin [email protected]
DocumentRoot /opt/openproject/public
ProxyRequests dezactivat
ProxyPass / http://127.0.0.1:6000/ retry=0
ProxyPassReverse / http://127.0.0.1:6000/
<LocationMatch „^/sys”>
<IfModule mod_authz_core.c>
Necesită local
</IfModule>
<IfModule !mod_authz_core.c>
Comanda refuza, permite
Negați din partea tuturor
Permite de la 127.0.0.1
</IfModule>
</LocationMatch>
Alias /assets /opt/openproject/public/assets
Alias /uploads /opt/openproject/public/uploads
<Directorul „/opt/openproject/public”>
Opțiuni -Indici
<IfModule mod_authz_core.c>
Solicitați toate acordate
</IfModule>
<IfModule !mod_authz_core.c>
Ordin refuza, permite
Permite de la toți
</IfModule>
</Director>
ProxyPass /active/ !
<Locație /active/>
FileETag Size
ExpirăActiv la expirăDefault „acces plus 1 an”
</Locație>
<FilesMatch „\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$”>
ExpirăActiv pe
ExpirăDefault „acces plus 1 an”
</FilesMatch>
AddOutputFilterByType DEFLATE text/html text/css application/x-javascript application/javascript
ErrorLog /var/log/apache2/openproject.example.com-error.log
Cand merg la https://example.com totul funcționează conform așteptărilor.
Cand merg la http://openproject.example.com totul funcționează conform așteptărilor.
din pacate http://example.com arată aplicația openproject și toate celelalte subdomenii, cum ar fi http://notexisting.example.com
Regula pentru http://example.com urmează să fie redirecționat către https://example.com
Cum se configurează așa cum era de așteptat?