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: Apache proxy in transperent mode
Author
akalaaji



Joined: 24 Apr 2007
Posts: 4

PostPosted: Tue 24 Apr '07 11:56    Post subject: Apache proxy in transperent mode Reply with quote

I have setup the Apache as a proxy on a dedicated machine and would like to access web traffic with it but it keeps showing my dedicated server IP and not my home IP. I lloked in many places but I can not find out how to make it transperent and the conf file did not have this option to forward x header so anyone here knows how it can be done? here is the the conf file



ServerRoot "C:/Program Files/Apache Software Foundation/Apache2.2"


Listen 443


LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule ssl_module modules/mod_ssl.so


ServerName myserver:80
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"


<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

</Directory>
#EnableMMAP off
#EnableSendfile off

ProxyRequests On
ProxyVia On
<Proxy *>
Order deny,allow
Deny from all
Allow from 86.97.0.0/16
Allow from 217.164.0.0/16
Allow from 217.165.0.0/16
</Proxy>

Mod note: Never post your whole config again! See the forum rules!
@jorge: I removed unneeded stuff
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Tue 24 Apr '07 14:32    Post subject: Reply with quote

I can't help you with the proxy stuff but try removing all the commends from your post so it's easier to read and spot possible errors!
Back to top
akalaaji



Joined: 24 Apr 2007
Posts: 4

PostPosted: Tue 24 Apr '07 20:07    Post subject: Reply with quote

Jorge wrote:
I can't help you with the proxy stuff but try removing all the commends from your post so it's easier to read and spot possible errors!


I'm not sure what you mean! Confused
Back to top
James Blond
Moderator


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

PostPosted: Tue 24 Apr '07 21:20    Post subject: Reply with quote

He means that you shouldn't post your whole config! Wink
By the way your config should work.Which question do youhave about that?
Back to top
akalaaji



Joined: 24 Apr 2007
Posts: 4

PostPosted: Wed 25 Apr '07 1:38    Post subject: Reply with quote

James Blond wrote:
He means that you shouldn't post your whole config! Wink
By the way your config should work.Which question do youhave about that?


I want the Apache proxy to show the client's IP address instead of the proxy server IP which is called transparent proxing but with this setting I tried browsing with the proxy from my home and sites identify the address as the proxy server and not my IP at home so I need Apache to add X-Forwarded-For request headers (like Squid ) So my IP is shown to the site.
Back to top
James Blond
Moderator


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

PostPosted: Wed 25 Apr '07 10:10    Post subject: Reply with quote

Apache forwards the Client IP with the HTTP_X_FORWARDED_FOR header. I think the Webpage shows only REMOTE_ADDR header which is the proxy.
So the webpage is not cleaver programmed.

To show the client IP makes no sense is a network. Most IP's are like 192.168.*.*


The following code would show the client IP.
Code:

<?php
if ($_SERVER['HTTP_X_FORWARDED_FOR'] != ""){
$IP = $_SERVER['HTTP_X_FORWARDED_FOR'];
$proxy = $_SERVER['REMOTE_ADDR'];
$host = @gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']);
}else{
$IP = $_SERVER['REMOTE_ADDR'];
$host = @gethostbyaddr($_SERVER['REMOTE_ADDR']);
}
if ($proxy=="") { $proxy = "none"; }
echo "<b>";
echo "your ip $IP";
echo "<br>";
echo "your proxy $proxy";
echo "<br>";
echo "your host $host";
echo "</b>";
?>
Back to top
akalaaji



Joined: 24 Apr 2007
Posts: 4

PostPosted: Wed 25 Apr '07 17:37    Post subject: Reply with quote

James Blond wrote:
Apache forwards the Client IP with the HTTP_X_FORWARDED_FOR header. I think the Webpage shows only REMOTE_ADDR header which is the proxy.
So the webpage is not cleaver programmed.

To show the client IP makes no sense is a network. Most IP's are like 192.168.*.*


The following code would show the client IP.
Code:

<?php
if ($_SERVER['HTTP_X_FORWARDED_FOR'] != ""){
$IP = $_SERVER['HTTP_X_FORWARDED_FOR'];
$proxy = $_SERVER['REMOTE_ADDR'];
$host = @gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']);
}else{
$IP = $_SERVER['REMOTE_ADDR'];
$host = @gethostbyaddr($_SERVER['REMOTE_ADDR']);
}
if ($proxy=="") { $proxy = "none"; }
echo "<b>";
echo "your ip $IP";
echo "<br>";
echo "your proxy $proxy";
echo "<br>";
echo "your host $host";
echo "</b>";
?>



So If I use this code It will work? what parts of the code do I have to edit server of course IP address and what else?
Back to top


Reply to topic   Topic: Apache proxy in transperent mode View previous topic :: View next topic
Post new topic   Forum Index -> Apache