logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Using Apache as proxy server
Author
Xia Jiang



Joined: 20 Oct 2009
Posts: 4

PostPosted: Tue 20 Oct '09 0:23    Post subject: Using Apache as proxy server Reply with quote

What I need is to use apache as a proxy server:
Say we have two ssl requests https://www.domain1.com and https://www.domain2.com
If the request is from https://www.domain1.com, we want to route it to 192.168.0.1; if request is from https://www.domain2.com, route it to 192.168.0.2.

Question 1:
How to configure the apache such that it can handle ssl request? I used mod_proxy together with ProxyPass for regular http request and it works fine. Can reverse proxy also work for SSL request?

Question 2:
Can apache route traffice based on the hostName?
ProxyPass only works for a sub-path like http://localhost/domain1 and http://localhost/domain2. How to access hostName?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Tue 20 Oct '09 10:38    Post subject: Reply with quote

For SSL connection you need to load mod_proxy_connect. The reverse isn't such different

Code:

NameVirtualHost *:443

<VirtualHost *:443>
ServerName www.domain1.com
ProxyPass / https://192.168.0.1/
ProxyPassReverse / https://192.168.0.1/
</VirtualHost>

<VirtualHost *:443>
ServerName www.domain2.com
ProxyPass / https://192.168.0.2/
ProxyPassReverse / https://192.168.0.2/
</VirtualHost>
Back to top
Xia Jiang



Joined: 20 Oct 2009
Posts: 4

PostPosted: Tue 20 Oct '09 18:42    Post subject: Reply with quote

Thanks for your reply. I think I've already have mod_proxy_connect loaded. Because when I do apachectl -l, mod_proxy_connect is already listed. and If I add "Load proxy_connect_module modules/mod_proxy_connect.so", it complains about "module proxy_connect_module is built-in and can't be loaded".

After I added those lines in between
<IfModule mod_proxy_connect.c> </IfModule>, I hit "https://www.domain1.com" I got "An error occurred during a connection to www.domain1.com. SSL received a record that exceeded the maximum permissible length."

Any idea?
Back to top
Xia Jiang



Joined: 20 Oct 2009
Posts: 4

PostPosted: Tue 20 Oct '09 19:12    Post subject: Reply with quote

Here I posted my conf file. Thanks.

Code:

ServerRoot "/usr/local/apache2"

Listen 443

DocumentRoot "/usr/local/apache2/htdocs"

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<Directory "/usr/local/apache2/htdocs">
   Options Indexes FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all
</Directory>

<IfModule alias_module>
  ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"

</IfModule>
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
<IfModule mod_proxy_connect.c>
NameVirtualHost *:443

<VirtualHost *:443>
ServerName www.domain1.com
ProxyPass / https://10.253.189.239:8081/
ProxyPassReverse / https://10.253.189.239:8081/
</VirtualHost>

<VirtualHost *:443>
ServerName www.domain2.com
ProxyPass / https://10.253.189.239:8082/
ProxyPassReverse / https://10.253.189.239:8082/
</VirtualHost>
</IfModule>



<Directory "/usr/local/apache2/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

DefaultType text/plain


<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>


Modnote: removed all not needed stuff


Last edited by Xia Jiang on Tue 20 Oct '09 23:52; edited 1 time in total
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Wed 21 Oct '09 11:23    Post subject: Reply with quote

Quote:

SSL received a record that exceeded the maximum permissible length."


You get that error because that address does not exist - either as an https or http address / or apache can't connect to it.
Back to top
Xia Jiang



Joined: 20 Oct 2009
Posts: 4

PostPosted: Wed 21 Oct '09 18:53    Post subject: Reply with quote

I switched to something like this :
ProxyPass / http://www.google.com/
which works fine for regular http request. " that address does not exist - either as an https or http address / or apache can't connect to it." which address do you mean here? is that "/" or "http://www.google.com/"
I also tried "ProxyPassMatch ^(.*) http://www.google.com" Same error.
Thanks again for your reply!
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Wed 21 Oct '09 20:28    Post subject: Reply with quote

That means the sever can't connect to https://10.253.189.239:8081 in this case. What is in your error log about that?
Back to top


Reply to topic   Topic: Using Apache as proxy server View previous topic :: View next topic
Post new topic   Forum Index -> Apache