views:

525

answers:

2

I need to find a way to proxy some traffic on port 80 to tinyproxy running on a separate port. We have a client working behind a very strict firewall with only port 80 open (and cannot get to sites like meebo.com, etc). I was hoping I could create a CNAME to our domain and a virtual host on apache, catch the request for that new CNAME and forward the traffic right to tinyproxy running on the same box.

I know tinyproxy is setup and working correctly, however, when I try to pass in my traffic through Apache, I don't even see any traffic.

Does anyone have a proposed solution? Here is my VirtualHost entry:

<VirtualHost *:80>
    ServerName sub.domain.com
    ProxyPass / http://127.0.0.1:50001/
    ProxyPassReverse / http://127.0.0.1:50001/
</VirtualHost>

where Tinyproxy is running on port 50001.

Thanks.

A: 

I don't think it's going to be possible.

ProxyPass is for opaque proxying of web-servers - not redirecting to a proxy. But it might have worked except that AFAIK VirtualHost can only be identified by the Host: header in the http request - so only works for the real request.

In other words - the clients will set a Host: header for the site they want to reach, so your virtualHost is never used.

Douglas Leeder
A: 

To clarify, the host-name of your domain is http://sub.domain.com/..., and you've verified that Tinyproxy serves your site when requested through tinyproxyhost:50001?

I would consider using iptables on your gateway to selectively NAT requests destined for sub.domain.com on port 80 to tinyproxyhost on port 50001. Assuming sub.domain.com is at address 12.34.56.78, and that tinyproxy is running on 10.11.12.13:

iptables -t nat -A PREROUTING -p tcp -d 12.34.56.78 --dport 80 -j DNAT \
    --to 10.11.12.13:50001

If you really want to continue using Apache for this, are you sure you've enabled mod_proxy completely? Ensure you have the following in your config too:

ProxyRequests Off


Order deny,allow
Allow from all

What happens when you try to access http://sub.domain.com in this configuration? What output do you get in your Apache access_log and error_log?

Roshan