I am limited to one external IP on my server thus to run a mail server alongside with other Apache instance for web hosting, I believe I am forced to use mod_proxy.
I tried using mod_proxy in the past but I recall only to get it to work within my internal network, but I need this to work outside of my network.
The mail server is on a VM which is on the same server as the other sites, but I have it setup as a bridged network so the VM has a different internal IP.
A few extra notes:
- The main server internal IP is 192.168.1.59
- Mail Server internal IP is 192.168.1.171
- My main site must preserve the HTTPS certificate/rewrite I created. If possible, it would be nice to use the same key on the mailserver.
- Everything is running on Debian 7.7 (includes the VM). Both instances are fully up to dates, etc.
/etc/apache2/ports.conf:
########## Global Properties ############################ # Ensure that Apache listens on port 80/443 Listen 80 Listen 443 # Listen for virtual host requests on all IP addresses NameVirtualHost *:80 NameVirtualHost *:443 <Proxy *> Order Allow,Deny Allow from all </Proxy> ProxyRequests Off ########################################################## ############## SSL Properties ########################## <VirtualHost *:443> DocumentRoot /var/www/site1.net SSLEngine On SSLCertificateFile /etc/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.key </VirtualHost> <IfModule mod_gnutls.c> Listen 443 </IfModule> ########################################################## ################### Websites ########################### <VirtualHost *:80> DocumentRoot /var/www/site1.net/ ServerName site1.net RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [R,L] </VirtualHost> <VirtualHost *:80> ServerName http://www.mail.site1.net ProxyPreserveHost On ProxyPass / http://192.168.1.171:80/mail/ ProxyPassReverse / http://192.168.1.171:80/mail RewriteRule ^/(.*)$ http:///192.168.1.171:80/mail/$1 [P,L] </VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/site2.com/ ServerName www.site2.com </VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/site2.com/ ServerName site2.com </VirtualHost>
It is not like this is the only thing I have tried, but after so long I forget what I have tried myself.. Just hoping someone else has more experience. Thanks for any help!