Forum archive
How to configure apache2 as reverse proxy as gateway for different turnkeys
Hi,
in the moment i use a turnkey lamp on my own vsphere enviroment. I have one static IP and connected my domain-name via DNS-A-Record to this IP and the turnkey lamp. Everything works fine.
Now i want to use a second turnkey lamp with a subdomain over the same IP. So i connected the new subdomain via DNS-A-Record to my static IP and the requests arrives on the 1st turnkey lamp. Now i enabled the proxy module on the 1st turnkey lamp and use the following configuration:
/etc/apache2/mods-enabled/proxy.conf:
ProxyRequests Off
<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
</Proxy>
ProxyVia On
/etc/apache2/sites-available/default
NameVirtualHost subdomain.example.com:80
<VirtualHost subdomain.example.com:80>
ServerName subdomain.example.com
ProxyPass / http://192.168.2.12:80/
ProxyPassReverse / http://192.168.2.12:80/
</VirtualHost>
NameVirtualHost subdomain.example.com:443
<VirtualHost subdomain.example.com:443>
ServerName subdomain.example.com
ProxyPass / https://192.168.2.12:443/
ProxyPassReverse / https://192.168.2.12:443/
</VirtualHost>
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.example.com
Redirect permanent / https://www.example.com/
</VirtualHost>
NameVirtualHost *:443
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /var/ssl/www.example.com.crt
SSLCertificateKeyFile /var/ssl/www.example.com.key
SSLCACertificateFile /var/ssl/intermediate.crt
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/
</VirtualHost>
.../etc/hosts
127.0.0.1 localhost 127.0.1.1 lamp 192.168.2.8 www.example.com 192.168.2.12 subdomain.example.com
The apache-server starts without any error or warning, but the routing to the new turnkey lamp does not work? All requests to the subdomain are processed by the 1st turnkey lamp.
Can everybody help? What's wrong on my configuration?
Thanks!
The main problem is the SSL handshake. The first turnkey must handle the SSL handshake before any request will be processed. So i have changed the configuration:
/etc/apache2/sites-available/default:
NameVirtualHost *:80 <VirtualHost *:80> ServerName www.example.com Redirect permanent / https://www.example.com/ </VirtualHost> <VirtualHost *:80> ServerName subdomain.example.com Redirect permanent / https://subdomain.example.com/ </VirtualHost> NameVirtualHost *:443 <VirtualHost *:443> SSLEngine on SSLCertificateFile /var/ssl/www.example.com.crt SSLCertificateKeyFile /var/ssl/www.example.com.key SSLCACertificateFile /var/ssl/intermediate.crt ServerName www.example.com ServerAlias example.com DocumentRoot /var/www/admin-interface/public </VirtualHost> <VirtualHost *:443> SSLEngine on SSLCertificateFile /var/ssl/subdomain.example.com.crt SSLCertificateKeyFile /var/ssl/subdomain.example.com.key SSLCACertificateFile /var/ssl/intermediate.crt ServerName subdomain.example.com ProxyPass / https://192.168.2.12:443/ ProxyPassReverse / https://192.168.2.12:443/ </VirtualHost>Now the SSL handshake works, but now i got an error on the page:
Bad Request
Your browser sent a request that this server could not unterstand.