Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've looking aroung the web, but I can't figure out how to do what I'm looking for. So what I'm looking for is a proxy on which will foward the HTTP query based on the IP address I've put in the url (GET).

So, for example :

I request : http://host/query/IP_A What it should do is : ME => GET HTTP myhost/query/IP_A => GET IP_A ===> GET HTTP query to IP_A and return to the sender!

I've been reading for proxypass, reverseproxy,proxymatch and mod_rewrite... but I can't figure out why it's not working at all! And I've no logs.... which is it not cool when came the debug time! :-(

here's my actual config :

<VirtualHost *:80>
 ServerName myServer
 DocumentRoot /home/me/www/htdocs
 #       RewriteCond ^.*/query/(.*)
 #       RewriteRule (.*) http://$1 [P]
 ProxyPassMatch ^.*/query/(.*) http://$1
 ErrorLog logs/me-error_log
 CustomLog logs/me-access_log debug
</VirtualHost>

Here's a static working example :

ProxyPass / http://IP_A
ProxyPassReverse / http://IP_A

So when I access to the webserver, it direct to the IP and return me the http response.

Thx for the help!

share|improve this question
1  
What's your use case here? As specified, it seems like a security nightmare. –  EEAA Jul 30 '13 at 20:56
    
Yes, but there's always a way to secure : the access, and IP Range on which we allowed the HTTP query. And the server is only allow to make some query on some specific IP range. –  user183729 Jul 31 '13 at 15:24

1 Answer 1

up vote 0 down vote accepted

Your use case is a little unclear. It sounds a lot like a normal web proxy (which accepts requests from your browser and then fetches content from the remote site on behalf of your browser).

But to do what you want:

<VirtualHost *:80>
    RewriteRule ^/query/(.*) http://$1 [P]
<VirtualHost *:80>

This will take anything about /query/ and append it to http://, and then make a proxy request for the result. As @EEAA said, this is a security nightmare (someone can use your server to attack a remote system), but it will do what you want.

You may want to read up on using Apache as a forward proxy (as described in the mod_proxy documentation, or here for example), and see if that meets your needs.

share|improve this answer
    
Hi! thx for the answers. Sorry if I was unclear, I taught I was! :-) I was reading about the mod_proxy but it doesn't seems that proxypass and proxyreverse can handle regex. For your info, my server only allow to do some HTTP query on specific IP address. Also, I guess the http query can be control by .htaccess so on a security point of view, it may be ok... event if it's not perfect. I'll give a try with your proposition. –  user183729 Jul 31 '13 at 15:32
    
You're welcome. If this answer helped out, consider marking it as "accepted" by clicking on the checkbox at the upper left of the answer. –  larsks Jul 31 '13 at 15:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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