squid后面的lighttpd日志记录用户ip的方法

默认在lighttpd的accesslog里面无法记录透过squid或者apache的mod_proxy过来的用户ip地址,全都会记录到squid或者apache机器的ip地址,但是httpd头里面的用户ip其实是发送到lighttpd的,可以通过修改accesslog.format来达到目的,下面是我的格式,跟combined兼容:

accesslog.format  = "%{X-Forwarded-For}i %v %u %t \"%r\" %s %b  \"%{User-Agent}i\" \"%{Referer}i\""

其中”%{X-Forwarded-For}i 就是记录了用户来源的ip地址

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
7 Responses
  1. 喜欢BSD says:

    不错的小经验,感谢楼主!

  2. flying says:

    如果是一层以上代理可怎么办呀?

  3. flying says:

    或者,如果是cdn服务器,既有通过squid过来的访问,也有直接从用户过来的访问,可怎么弄啊

  4. Michael says:

    [Comment ID #18069 Will Be Quoted Here]

    这样的情况下,基本上都是收集squid的日志进行统计分析,而不是分析后端日志了。

  5. suchasplus says:

    呵呵
    楼主的方法不错
    不过还有一个官方方法,不需要修改accesslog.format
    启用mod_extforward即可
    mod_extforward – extract the client’s “real” IP from X-Forwarded-For header
    http://redmine.lighttpd.net/wiki/lighttpd/Docs#Options-for-mod_extforward-extract-the-clients-real-IP-from-X-Forwarded-For-header
    btw:lighttpd什么时候抛弃trac了???

  6. suchasplus says:

    [Comment ID #30234 Will Be Quoted Here]
    严格来说, X-Forwarded-For header的值不能完全信任..Lighttpd的extforword可以限定来源地址,对非信任地址直接记录成127.0.0.1
    当初测试端口转发的时候发现sina的后端apache都限定了来源地址,必须从前端squid走

  7. Michael says:

    谢谢,说得很好 🙂

  8. minecraft says:

    Hmm is anyone else encountering problems with the pictures on this blog loading?

    I’m trying to figure out if its a problem on my end or if it’s the blog.
    Any responses would be greatly appreciated.

  9. minecraft says:

    If you wish for to obtain much from this article then you have
    to apply these strategies to your won web site.

  10. Awesome! Its truly awesome piece of writing, I have got much clear idea on the topic of from this article.

  11. Usually I do not read post on blogs, but I wish to say that this
    write-up very compelled me to try and do it! Your writing taste has been amazed me.
    Thank you, very nice post.

  12. What’s up, yes this post is actually good
    and I have learned lot of things from it about blogging. thanks.

  13. Peculiar article, totally what I was looking for.

  14. Hi would you mind sharing which blog platform you’re using?
    I’m planning to start my own blog soon but I’m having a
    hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs and I’m looking for something completely unique.
    P.S My apologies for being off-topic but I had to ask!

  15. If you are going for best contents like me, just pay
    a quick visit this website every day since it presents quality
    contents, thanks

  16. I would like to thank you for the efforts you’ve put in writing this website.
    I’m hoping to view the same high-grade blog
    posts by you later on as well. In truth, your creative writing abilities
    has inspired me to get my own, personal site now 😉

  17. Awesome website you have here but I was curious if you knew of any discussion boards that
    cover the same topics talked about here? I’d really love to be a
    part of online community where I can get advice from other knowledgeable individuals that
    share the same interest. If you have any recommendations, please let me know.
    Thank you!

  18. Thanks on your marvelous posting! I truly enjoyed reading it, you
    might be a great author. I will make sure to bookmark your blog and may come
    back at some point. I want to encourage you to ultimately continue your great writing, have a nice morning!

  19. What i do not realize is in truth how you are no longer actually much more neatly-liked
    than you might be now. You’re so intelligent.
    You recognize therefore considerably when it
    comes to this matter, made me individually imagine it from numerous various angles.
    Its like women and men are not involved unless it is one thing to do
    with Girl gaga! Your individual stuffs nice.
    Always maintain it up!

  20. After looking into a few of the blog articles on your site, I truly appreciate your way of blogging.
    I saved it to my bookmark site list and will be checking back soon. Please check out my
    web site too and tell me how you feel.

  21. Sling TV says:

    I really like your blog.. very nice colors & theme.
    Did you create this website yourself or did you hire someone to
    do it for you? Plz answer back as I’m looking to design my own blog and would like to
    know where u got this from. thanks a lot

  22. Sling TV says:

    Excellent pieces. Keep posting such kind of info on your blog.
    Im really impressed by it.
    Hi there, You have done a fantastic job. I’ll definitely digg it and individually suggest to
    my friends. I’m sure they’ll be benefited from this website.

  23. Hi, i think that i saw you visited my site so i came to “return the favor”.I’m trying to find things to enhance my
    web site!I suppose its ok to use a few of your
    ideas!!

  24. What’s Taking place i am new to this, I stumbled
    upon this I have discovered It absolutely useful and it has aided me
    out loads. I hope to give a contribution & aid different
    users like its helped me. Great job.

  25. sling tv coupons and promo codes for november 2018
    It’s difficult to find knowledgeable people on this subject, however,
    you sound like you know what you’re talking about! Thanks sling tv coupons and promo codes for november 2018

  26. Write more, thats all I have to say. Literally, it seems as though you relied
    on the video to make your point. You obviously know what youre talking about, why waste your intelligence on just posting videos to your blog when you could be giving us something enlightening to read?

  27. Very descriptive post, I loved that bit. Will
    there be a part 2?

  28. It’s very easy to find out any matter on web as compared to books, as I found
    this post at this web page.

  29. Excellent article. I definitely appreciate this website.
    Continue the good work!

  30. minecraft says:

    I appreciate, cause I discovered exactly what I used
    to be looking for. You’ve ended my 4 day lengthy hunt!
    God Bless you man. Have a great day. Bye

  31. download says:

    I do not even know how I ended up here, but I thought this post was great.
    I do not know who you are but definitely you are going to
    a famous blogger if you aren’t already 😉 Cheers!

  32. minecraft says:

    My spouse and I stumbled over here coming from a different page and thought I might
    check things out. I like what I see so now i’m following you.

    Look forward to finding out about your web page
    again.

  33. Simply desire to say your article is as astonishing.
    The clarity on your put up is just great and that i could assume you
    are a professional on this subject. Well along with your permission allow me to snatch your
    RSS feed to keep updated with forthcoming post.
    Thanks 1,000,000 and please carry on the gratifying work.

  34. minecraft says:

    I’m gone to convey my little brother, that he should also go to see this
    weblog on regular basis to obtain updated from latest news update.

  35. minecraft says:

    Thanks for your personal marvelous posting! I definitely enjoyed
    reading it, you’re a great author.I will make certain to bookmark your blog and will often come back later
    on. I want to encourage you to ultimately continue your great
    writing, have a nice holiday weekend!

  36. Simply wish to say your article is as surprising. The clearness for your submit is simply excellent and i could assume you’re
    a professional in this subject. Well with your permission allow me to clutch your feed to keep up to date with imminent post.
    Thanks a million and please carry on the rewarding work.

  37. minecraft says:

    Hi there! I simply want to offer you a big thumbs up for your excellent information you have right here
    on this post. I will be returning to your site for more soon.

  38. tinyurl.com says:

    Howdy are using WordPress for your site platform? I’m new to the blog world but I’m trying to
    get started and set up my own. Do you require any
    coding knowledge to make your own blog? Any help would be greatly
    appreciated!

  39. Spot on with this write-up, I honestly believe this amazing site needs far more attention. I’ll probably
    be back again to read more, thanks for the info!

  40. Very good site you have here but I was curious about if you knew of any message boards that cover the same topics discussed in this article?
    I’d really love to be a part of group where I can get feedback
    from other experienced individuals that share
    the same interest. If you have any suggestions, please let me know.
    Thanks!

  41. g says:

    Hi there, just became alert to your blog through Google, and found that it is truly informative.
    I’m going to watch out for brussels. I’ll be grateful if you continue this
    in future. Lots of people will be benefited from your writing.

    Cheers!

  42. g says:

    Write more, thats all I have to say. Literally, it seems as though you
    relied on the video to make your point. You clearly know what youre talking
    about, why throw away your intelligence on just posting videos to your site
    when you could be giving us something enlightening to read?

  43. g says:

    Undeniably imagine that which you stated. Your favorite justification appeared to be
    on the net the simplest factor to have in mind of. I say to you, I definitely get annoyed
    whilst other folks think about issues that
    they just don’t know about. You controlled to
    hit the nail upon the highest as neatly as outlined out the whole thing without having side-effects , other people could take
    a signal. Will likely be back to get more.

    Thanks

  44. g says:

    It’s amazing in favor of me to have a web page, which is good
    in favor of my experience. thanks admin

  45. Great article, just what I wanted to find.

  46. Way cool! Some extremely valid points! I appreciate you penning this post and
    the rest of the website is also really good.

  47. I’m gone to say to my little brother, that he should also pay a visit this blog on regular basis to obtain updated from most recent news.

  48. Hi, for all time i used to check weblog posts here early in the break of day, because i enjoy
    to learn more and more.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image