The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

X-Forwarded-for

Discussion in 'Security' started by dragon2611, Dec 6, 2009.

  1. dragon2611

    dragon2611 Well-Known Member

    Joined:
    Nov 30, 2003
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    Can someone suggest the best way of reading the X-Forwarded-for header and putting the IP in the apache logs as well as the real IP as I've been experimenting with putting a proxy cache infront of my apache server to see if it speeds things up.

    Problem is now of course all the requests in the logs show the proxy ip instead of the actual IP, ideally i'd like the logs to show the actuall ip and what x-forwarded-for is coming up with.
     
    #1 dragon2611, Dec 6, 2009
    Last edited: Dec 6, 2009
  2. dragon2611

    dragon2611 Well-Known Member

    Joined:
    Nov 30, 2003
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    after much googling I've changed httpd.conf to the following


    Code:
    <IfModule log_config_module>
    
    <IfModule log_config_module>
    #LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    
    
    I deliberaly left in the logging of the host IP as it allows me to enable/disable the proxy easily and not have to remember to log the actual ip. ;)
     
    #2 dragon2611, Dec 7, 2009
    Last edited: Dec 7, 2009

Share This Page