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?

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.

| improve this answer | |
  • Note: I had to add :443 to the Servername directive to make it work with https. – Gerald Schneider Aug 20 '14 at 9:15
  • Note 2: You have to use two different VirtualHost entries for http and https for your second domain. You need to set the SSL entries for https and not for http. – Gerald Schneider Aug 20 '14 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.