0

I have a mail server setup for a domain using postfix. For the ssl cert, I have created a virtual host for that mail server. The virtual host look like this

<VirtualHost *:80>
  ServerName mail.domainX.net
  DocumentRoot /var/www/roundcube/

  ErrorLog ${APACHE_LOG_DIR}/mail.domainX.net_error.log
  CustomLog ${APACHE_LOG_DIR}/mail.domainX.net_access.log combined

  <Directory />
    Options FollowSymLinks
    AllowOverride All
  </Directory>

  <Directory /var/www/roundcube/>
    Options FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

RewriteEngine on
RewriteCond %{SERVER_NAME} =mail.domainX.net
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

My problem is when I hit mail.domain.com in the browser it opens the webpage for another domain set up on my server using apache virtual host. How can I stop this from the browser?

Thanks in advance.

Saaram
  • 101
  • 1
    Is the configuration file really loaded? Did you restart or reload the apache process after editing the configuration file? Is the domain used in another configuration file? – Gerald Schneider Nov 24 '21 at 11:44
  • yes, its loaded, I have restarted as well. What do you mean by domain used in another config ? – Saaram Nov 24 '21 at 12:31
  • 1
    You have there a plain HTTP virtual host that is configured with a permanent redirect to the corresponding HTTPS URL. If there is no HTTPS / SSL VirtualHost for mail.domainX.net configured (but the servers SSL certificate does include that hostname and you don't get an certificate warning) the default virtual host for HTTPS / SSL / TLS requests will be used by Apache. – Bob Nov 24 '21 at 12:41
  • so should I remove this line ? '''RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]''' – Saaram Nov 24 '21 at 12:56
  • 1
    That and clear your bowser cache (permanent redirects are cached) OR set up a SSL virtual host for for mail.domainX.net – Bob Nov 24 '21 at 13:12

0 Answers0