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 have a VPS and want to used a forward proxy set-up so that I can appear to be browsing from my VPS IP address rather than my client address. If I set up a proxy directive in httpd.config like this:

<IfModule proxy_module>
  <IfModule proxy_http_module>

    ProxyRequests On
    ProxyVia On

    <Proxy *>
      Order Deny,Allow
      Deny from all
      Allow from (**client ip address**)
    </Proxy>

  </IfModule>
</IfModule>

... I think this will only allow my client ip address to use the proxy BUT will also prevent the rest of the world accessing web pages from my server.

Is there a way of putting all this into a virtualhost or .htaccess directive so that the proxy only 'kicks in' when accessed through a specific URL?

share|improve this question

1 Answer 1

Absolutely, see the "context" lines for various apache proxy directives that can be used in virtual hosts: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html . I don't think you'll be able to use .htaccess for this purpose.

Update:

Your configs look correct, however, start with this in your <VirtualHost> configs:

  • Drop the <ifmodule> tags -- as long you have the necessary LoadModule lines somewhere earlier in the confs

Update: Something like this should set you on the right path. Note, this is untested.

<VirtualHost *:80>
ServerName myproxydomain.com

    ProxyRequests On
    ProxyVia On

    ProxyPass / http://domaintoproxy.com/
    ProxyPassReverse / http://domaintoproxy.com/

    <Proxy *>
      Order Deny,Allow
      Deny from all
      Allow from (**client ip address**)
    </Proxy>

</VirtualHost>

share|improve this answer
    
Can you give me a code example? I tried just adding exact code above into a <VirtualHost *:80> definition - specifying a servername. But when I accessed the servername from a non-allowed IP address it still served the files instead of giving a 403 response. –  Owen Aug 22 '12 at 17:58
    
Ah, you're missing ProxyPass lines. See update. –  KM. Aug 22 '12 at 19:15
    
I'm trying to set up a Forward proxy. ProxyPass is just for Reverse proxy, isn't it? –  Owen Aug 22 '12 at 21:55
    
Douh, of course! Mea culpa. See updated answer. –  KM. Aug 23 '12 at 1:53

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.