I have an Apache web server that also runs my Gitlab server and now I'm trying to make it a mail server too. Various tutorials told me that I needed to start with adding some DNS entries and getting those cleared with Spamhaus. So I logged into GoDaddy and I made these records:
A @ (my Amazon elastic IP)
A gitlab (my Amazon elastic IP)
A mail (my Amazon elastic IP)
CNAME www @
MX @ mail.example.com
Does that look normal so far? Besides that I have some mandatory NS and SOA records.
Previously, I had my httpd.conf file set up to handle my gitlab subdomain and redirect http to https. But now for some reason I'm able to browse to mail.example.com and it takes me to my gitlab.example.com login page. This is extremely vexing because I never even entered the mail subdomain as a VirtualHost in my httpd.conf file. Now I'm trying unsuccessfully to get rid of it. This is the relevant section of my httpd.conf:
Listen 80
ServerName example.com
DocumentRoot "/var/www/html"
<VirtualHost *:80>
ServerName gitlab.example.com
ServerAlias gitlab.example.com
ServerSignature Off
RewriteEngine on
RewriteCond %{HTTP_HOST} ^gitlab.example.com$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [NE,R,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteCond %{SERVER_NAME} =gitlab.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:80>
ServerName mail.example.com
RedirectPermanent / https://example.com:443
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLProtocol all -SSLv2
SSLHonorCipherOrder on
SSLCipherSuite "...(a bunch of letters and numbers)..."
Header add Strict-Transport-Security: "max-age=15768000;includeSubdomains"
SSLCompression Off
SSLCACertificateFile /etc/httpd/ssl.crt/cert.pem
ServerName gitlab.example.com
ServerAlias gitlab.example.com
ServerSignature Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Location />
Require all granted
ProxyPassReverse http://127.0.0.1:8181
ProxyPassReverse http://gitlab.example.com/
</Location>
RewriteEngine on
RewriteCond %{REQUEST_URI> ^/api/v3/.*
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
(Locations of error documents, logs, certificates...)
</VirtualHost>
Can anyone look at that and tell my why mail.mydomain redirects to my Gitlab? I would prefer that it just not go anywhere except maybe to a 404 error.