Apache vhost using wrong DocumentRoot

I am configuring a webmail on my Apache/2.4.25 server, and I’m having problems with redirecting to one of the subdomains. I’m currently unsing (probably in the most inelegant way) one .conf file for every vhost.

The content of this .conf is:

<VirtualHost *:80>     ServerName webmail.vignati.eu     DocumentRoot /var/www/vhosts/webmail.vignati.eu     DirectoryIndex index.htm index.html index.php     ServerAlias vignati.eu     ErrorDocument 404 /404.html     ErrorDocument 500 /50x.html     ErrorDocument 502 /50x.html     ErrorDocument 503 /50x.html     ErrorDocument 504 /50x.html     ErrorLog /var/log/apache2/webmail.vignati-eu_error_log     CustomLog /var/log/apache2/webmail.vignati.eu_access_log combined     <Directory /(README.md|INSTALL|LICENSE|CHANGELOG|UPGRADING)$  >             Order Deny,Allow             Deny from all     </Directory>     <Directory /(bin|SQL|config|temp|logs)/>             Order Deny,Allow             Deny from all     </Directory> </VirtualHost>  <VirtualHost *:80>     ServerName mail.vignati.eu     DocumentRoot /var/www/vhosts/mail.vignati.eu/public-html     DirectoryIndex index.htm index.html index.php     ServerAlias vignati.eu     ErrorDocument 404 /story.php     ErrorLog /var/log/apache2/mail.vignati-eu_error_log     CustomLog /var/log/apache2/mail.vignati.eu_access_log combined     Redirect permanent / https://mail.vignati.eu/ </VirtualHost> [...] 

The file goes on with the configuration of www. and the https configurations for www. and mail. (which all work fine)

My problem is that when I try to navigate to webmail.vignati.eu, I get redirected to the index.html file that is in

DocumentRoot /var/www/vhosts/mail.vignati.eu/public-html 

But the correct DocumentRoot, as specified in the vhost is

DocumentRoot /var/www/vhosts/webmail.vignati.eu 

Could anyone help me find what I’m getting wrong?

(The server is switched-off at the moment, so if anyone wanted to check by themselves, sorry, but it’s not possible)

nginx ssl_dhparam key for each vhost, or once for entire configuration? vs SSL confg

Should diffie hellman parameters (ssl_dhparam key) be generated for each vhost, or just placed within http{...}? (for completely different website served up by the same host.

Conversely, to confirm, ssl_certificate, ssl_certificate_key, ssl_trusted_certificate should be different for each website? Is there a way to refer to these three parameters if used in multiple vhosts (e.g. forwarding none www to www) without copy pasting? (Trying to follow the DRY principle, one source of truth)

Apache2 Vhost HTTP to HTTPS Redirect not working in a strange way

I set up HTTPS for my website for the first time today. I started with the following code:

<VirtualHost *:443>     ServerName website.tld     DocumentRoot /var/www/website.tld      SSLEngine on     SSLCertificateFile /etc/apache2/ssl/website.tld.crt     SSLCertificateKeyFile /etc/apache2/ssl/website.tld.key      ErrorLog $  {APACHE_LOG_DIR}/error.log     CustomLog $  {APACHE_LOG_DIR}/access.log combined      <Directory /var/www/website.tld/>             Options Indexes FollowSymLinks MultiViews             AllowOverride All             Order allow,deny             allow from all         </Directory> </VirtualHost> 

which totally worked fine. Now I wanted the website to redirect http to https and added the following at the top:

<VirtualHost *:80>     ServerName website.tld     ServerAlias www.website.tld     Redirect 301 / https://website.tld </VirtualHost>  <VirtualHost *:443>      ServerName www.website.tld      Redirect 301 / https://website.tld </VirtualHost> 

Now if I access the website from http it redirects to https, BUT once I’m on the https site I get an error from Chrome saying “ERR_SSL_PROTOCOL_ERROR”. Can somebody help?

new vhost redirect to other vhost (rspamd)

actually setup a new apache vhost for a second domain on my debian vps.

Every time i browse the new domain, it redirect to my rspamd vhost. My first domain working fine, the rspamd redirect working fine but not the second tld. Its redirecting to https://mail.domain.tld/rspamd

here the 3 vhosts:

mail.domain.tld

    <VirtualHost *:80>     ServerName mail.domain.tld     RedirectPermanent http://mail.domain.tld https://mail.domain.tld/rspamd/  </VirtualHost>   <VirtualHost *:443>     ServerName mail.domain.tld     RedirectPermanent https://mail.domain.tld https://mail.domain.tld/rspamd/      ###     ### Rspamd     ###      RewriteEngine on     RewriteRule ^/rspamd$   /rspamd/ [R]      ProxyPreserveHost On     ProxyPass /rspamd http://localhost:11334/     ProxyPassReverse /rspamd http://localhost:11334/      SSLEngine on     SSLHonorCipherOrder on     SSLCertificateFile /etc/letsencrypt/live/domain.tld-0002/fullchain.pem     SSLCertificateKeyFile /etc/letsencrypt/live/domain.tld-0002/privkey.pem      Include /etc/letsencrypt/options-ssl-apache.conf  </VirtualHost> 

domain.tld

<VirtualHost *:80>          ServerName domain.tld         ServerAlias www.domain.tld         ServerAdmin webmaster@domain.tld         DocumentRoot /var/www/domain.tld/web/          #LogLevel info ssl:warn          ErrorLog $  {APACHE_LOG_DIR}/error.log         CustomLog $  {APACHE_LOG_DIR}/access.log combined  RewriteEngine on RewriteCond %{SERVER_NAME} =www.domain.tld [OR] RewriteCond %{SERVER_NAME} =domain.tld RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost>  <IfModule mod_ssl.c> <VirtualHost *:443>          ServerName domain.tld         ServerAlias www.domain.tld         ServerAdmin webmaster@domain.tld         DocumentRoot /var/www/domain.tld/web/      Alias /phpmyadmin "/usr/share/phpmyadmin/"     <Directory "/usr/share/phpmyadmin/">         Order allow,deny         Allow from all                 AuthType Basic                 AuthName "Restricted Content"                 AuthUserFile /etc/apache2/.htpasswd                 Require valid-user     </Directory>          <Directory "/var/www/domain.tld/web/">                 AllowOverride All                 Order allow,deny                 Allow from all                 Require all granted                 Options -Indexes         </Directory>           #LogLevel info ssl:warn          ErrorLog $  {APACHE_LOG_DIR}/error.log         CustomLog $  {APACHE_LOG_DIR}/access.log combined  Include /etc/letsencrypt/options-ssl-apache.conf SSLCertificateFile /etc/letsencrypt/live/domain.tld-0002/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/domain.tld-0002/privkey.pem  RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$   http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]  </VirtualHost> </IfModule> 

domain2.tld:

        ServerName domain2.tld         ServerAlias www.domain2.tld         ServerAdmin webmaster@domain.tld         DocumentRoot /var/www/domain2.tld/web/          <Directory "/var/www/domain2.tld/web/">                 AllowOverride All                 Order allow,deny                 Allow from all                 Require all granted                 Options -Indexes         </Directory>       RewriteEngine On     RewriteCond %{HTTP_HOST} !^www\. [NC]     RewriteRule ^(.*)$   http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]           #LogLevel info ssl:warn          ErrorLog $  {APACHE_LOG_DIR}/error.log         CustomLog $  {APACHE_LOG_DIR}/access.log combined  </VirtualHost> 

Anybody know what i’m doing wrong?