Visit Our UNIX and Linux User Community


Apache: Forward Proxy Via Virtualhost


 
Thread Tools Search this Thread
Top Forums Web Development Apache: Forward Proxy Via Virtualhost
# 1  
Old 07-29-2009
Apache: Forward Proxy Via Virtualhost

I've set up a forward proxy within a VirtualHost (see below) on Apache 2.2.11. I then browse using mydomain.com:80 as the proxy - I've also tried using the IP address of the VirtualHost xxx.xxx.xxx.xxx:80. It works fine, the only problem is that in both cases the server's main IP address is always displayed at the other end. Is there a way to make it so that the individual IP of the VirtualHost is shown instead?

I've tested the proxy via other VirtualHosts on the server and it doesn't work, so I know that it's being properly channelled through this one.

Code:
NameVirtualHost xxx.xxx.xxx.xxx:80
<VirtualHost xxx.xxx.xxx.xxx:80>
   ServerName mydomain.com
   DocumentRoot /xxx/xxx/public_html
   ServerAdmin xxx@xxx.com
   ProxyRequests On
   ProxyVia On
   <Proxy *>
      Order deny,allow
      Allow from xxx.xxx.xxx.xxx
   </Proxy>
</VirtualHost>

# 2  
Old 07-29-2009
You should use the ProxyPass and ProxyPassReverse directives to get this working rather than the Proxy directive.

mod_proxy - Apache HTTP Server
# 3  
Old 07-29-2009
Thanks for the reply, I tried your suggestion (see below). This produces a mirror of the external site (at http://mysite.com/mirror/), but the main IP of the server (instead of the VirtualHost IP) is still showing at the other end - I'm talking about the REMOTE_ADDR environment variable. I want it to be the individual IP address of the VirtualHost instead of the server's main/global IP.

Code:
NameVirtualHost xxx.xxx.xxx.xxx:80
<VirtualHost xxx.xxx.xxx.xxx:80> # I want this IP address to show as the REMOTE_ADDR
   ServerName mydomain.com
   DocumentRoot /xxx/xxx/public_html
   ServerAdmin xxx@xxx.com
   ProxyPass /mirror/ http://externalsite.com/
   ProxyPassReverse /mirror/ http://externalsite.com/
   <Proxy *>
      Order deny,allow
      Allow from xxx.xxx.xxx.xxx
   </Proxy>
</VirtualHost>


Last edited by krunksta; 07-30-2009 at 12:04 AM..

Previous Thread | Next Thread
Test Your Knowledge in Computers #178
Difficulty: Medium
The Apple Computer Company was founded on April 1, 1978.
True or False?

9 More Discussions You Might Find Interesting

1. Linux

Apache/2.2.25 VirtualHost not working

I am having problems in implementing the virtual hosts here in my server. I have this one cloud dev server: Amazon Linux AMI release 2013.03 (based on RHEL like CentOS) with Apache 2.2.25 installed and I'm trying to create 2 virtual hosts: test-kalc.tk and test2-kalc.tk. If I go to... (2 Replies)
Discussion started by: jpdoria
2 Replies

2. Web Development

Apache proxy for web app with ssl

I have a ubuntu server running subsonic as a web app. Currently the web interface is available from port 4040 for https connections and 4141 for https connections with the context /subsonic as follows: http://mydomain:4040/subsonic https://mydomain:4141/subsonic I would like to loose the port... (0 Replies)
Discussion started by: barrydocks
0 Replies

3. Red Hat

apache httpd virtual hosts setup keep hitting the same VirtualHost

I'm trying to set up two virtual hosts. Here's my httpd config: <Directory /Users/userX/dev/sandbox-2> Order deny,allow deny from All Allow from localhost </Directory> NameVirtualHost 127.0.0.1 <VirtualHost 127.0.0.1> DocumentRoot "/Users/userX/dev/sandbox-2" ... (0 Replies)
Discussion started by: GlideK
0 Replies

4. Ubuntu

Iptables forward traffic to forward chain!!!

Hi, I am new to linux stuff. I want to use linux iptables to configure rule so that all my incoming traffic with protocol "tcp" is forwarded to the "FORWARD CHAIN". The traffic i am dealing with has destination addresss of my machine but i want to block it from coming to input chain and somehow... (0 Replies)
Discussion started by: arsipk
0 Replies

5. Web Development

Apache virtualhost dinternal domain

Hello, I have have installed two web applications on one server with one IP address and one domain name (mynet.intra). Is it possible to configure in apache 2.2 that access to one application would be from "app1.mynet.intra" and to another application from address "app2.mynet.intra"? Document... (1 Reply)
Discussion started by: kreno
1 Replies

6. Web Development

Copy and forward apache http request

Hello, I am using apache 2.2 and I need to have certain http requests (those including example.com for instance) to be executed normally and forwarded to another server. With mod_rewrite, I could easily forward but then the input request would not be executed on my server. Right? Am I... (1 Reply)
Discussion started by: JCR
1 Replies

7. UNIX for Advanced & Expert Users

Apache-Reverse proxy and load balancing

Hi All, I have a webpage loaded on server1 with authorization enabled by .htaccess, which can be accessed by http://ipofserver1/index.html. Now im planning a high availabilty load balancing in such a way that if the server1 is down due to some reason it should connect to another server. i have... (1 Reply)
Discussion started by: Tuxidow
1 Replies

8. UNIX for Advanced & Expert Users

squid proxy and apache servers

hi. pardon my noob question id just like to have a quick answer. i am planning to install a jabber webclient and a jabber server in our apache server. my boss said this wouldnt work because squid filters port 5222 connections (jabber). i told him we can simply 'unfilter' the port then but he said... (0 Replies)
Discussion started by: marcpascual
0 Replies

9. UNIX for Dummies Questions & Answers

Apache httpd.conf <VirtualHost> issue

I have just configured httpd.conf on a new Redhat 9 install. Below are my additions to httpd.conf. Everything works fine except that when typing http://spetnik.d2g.com into my web browser, I am sent to the "Default catch all" site. Any clues? NameVirtualHost *:80 #Default catch all ... (5 Replies)
Discussion started by: Spetnik
5 Replies

Featured Tech Videos