# Show user's IP on tomcat's logs (6.x)

**URL:** <https://www.ruby-forum.com/t/show-users-ip-on-tomcats-logs-6-x/207927>\
**Category:** NGINX\
**Created:** [June 6, 2011, 4:11pm UTC](https://www.ruby-forum.com/t/show-users-ip-on-tomcats-logs-6-x/207927 "2011-06-06T16:11:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 6, 2011, 4:11pm UTC](https://www.ruby-forum.com/t/show-users-ip-on-tomcats-logs-6-x/207927/1 "2011-06-06T16:11:46Z")

</div>

hi all,  
today i put my nginx in production , listening on port 80.  
Requestes to www, pass-through proxy directive, will be sended to the  
localhost:82, where is the tomcat.  
Another site, blog.domain address is apache on the address localhost:81.

I installed the apache’s module rpaf and now I see in the logs IP  
addresses of users.

Is there any solution for the tomcat (6.x) to solve the problem too?

Thanks

here my default.conf

server {  
server\_name [www.domain.com](http://www.domain.com);  
location / {  
port\_in\_redirect off;  
proxy\_redirect off;  
proxy\_pass [http://localhost:82](http://localhost:82);  
proxy\_set\_header Host $host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For  
$proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header X-Forwarded-Host $host;  
proxy\_set\_header X-Forwarded-Port 80;  
}  
}  
server {  
server\_name [blog.domain.com](http://blog.domain.com);  
location / {  
port\_in\_redirect off;  
server\_name\_in\_redirect off;  
proxy\_redirect off;  
proxy\_pass [http://localhost:81](http://localhost:81);  
proxy\_set\_header Host $host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For  
$proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header X-Forwarded-Host $host;  
proxy\_set\_header X-Forwarded-Port 80;  
proxy\_set\_header X-Server-Address $server\_addr;  
}  
}

---

<div class="post-metadata">

**Author:** ![emarginated](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3e96dc/32.png) [@emarginated](https://www.ruby-forum.com/u/emarginated)\
**Post date:** [June 7, 2011, 3:46pm UTC](https://www.ruby-forum.com/t/show-users-ip-on-tomcats-logs-6-x/207927/2 "2011-06-07T15:46:02Z")

</div>

Is it an odd question?

---

<div class="post-metadata">

**Author:** ![emarginated](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3e96dc/32.png) [@emarginated](https://www.ruby-forum.com/u/emarginated)\
**Post date:** [June 8, 2011, 2:24pm UTC](https://www.ruby-forum.com/t/show-users-ip-on-tomcats-logs-6-x/207927/3 "2011-06-08T14:24:54Z")

</div>

Here it is the solution:

In server.xml, chanche the pattern"combined" of Log Valve, with this

pattern="%{X-Forwarded-For}i %l %u %t “%r” %s %b  
“%{Referer}i” “%{User-agent}i”"

This way you get the the various fields remain correctly grouped  
together when parsed.
