0

Uggh, I'm spewing that I can't figure this out, I'm so frustrated:

    <VirtualHost *:80>
        servername domain1.com.au
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <Proxy *>
          Order Allow,Deny
          Allow from all
        </Proxy>

        RewriteEngine on
        ReWriteCond %{SERVER_PORT} !^443$
        RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>

<VirtualHost *:443>

        servername domain1.com.au

        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/owncloud.pem
        SSLCertificateKeyFile /etc/apache2/ssl/owncloud.key
        DocumentRoot /var/www/html

</VirtualHost>

<VirtualHost *:*>
        Servername domain2.com.au
        ProxyRequests Off
        <Proxy *>
          Order deny,allow
          Allow from all
        </Proxy>

        ProxyPass / https://192.168.1.12/
        ProxyPassReverse / https://192.168.1.12/
</VirtualHost>

Not sure if it's clear what I'm trying to do, but I've read and read and READ, I still can't figure it out.

Basically I have a working Apache server with a rewrite to force HTTPS, as seen in the first two VirtualHost entries. I now have a webmail service I set up on another server, under another domain name, however I only have one incoming public IP address.

So I'm trying to have any incoming requests for the second domain to be proxied to the other server to access the webmail, whether its port 80 or 443.

IMAP and POP3 are no problems, I can just forward the ports directly to the correct server.

The results of the above configuration is that requests to domain2.com.au (port 80 or 443) are forwarded to https://domain1.com.au.

Am I headed in the right direction?

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89
mhouston100
  • 412
  • 1
  • 5
  • 20

1 Answers1

1

You need to set NameVirtualHost in your configuration for Servername to be effective.

NameVirtualHost *:80
NameVirtualHost *:443

If you don't set it the last block will take precedence and override the previous VirtualHost configurations.

See the documentation for details.

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89