Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
resin backend
Здравствуйте,
Сделал интересный патч к resin-3.0.18, функциональность как у mod_realip для
apache.
Подставляет remote address в логи и апплеты resin'а из X-Real-IP.
Может кому пригодится.
--
С уважением,
Роман Шишнёв,
e-mail: mailto:rommer@xxxxxxxxx
diff -Nru
a/modules/resin/src/com/caucho/server/connection/AbstractHttpRequest.java
b/modules/resin/src/com/caucho/server/connection/AbstractHttpRequest.java
--- a/modules/resin/src/com/caucho/server/connection/AbstractHttpRequest.java
2006-02-23 01:38:58.000000000 +0200
+++ b/modules/resin/src/com/caucho/server/connection/AbstractHttpRequest.java
2006-03-01 15:02:32.000000000 +0200
@@ -390,20 +390,40 @@
public String getRemoteAddr()
{
- return _conn.getRemoteHost();
+ String realip = getHeader("X-Real-IP");
+
+ if (realip == null)
+ return _conn.getRemoteHost();
+
+ return realip;
}
public int printRemoteAddr(byte []buffer, int offset)
throws IOException
{
- int len = _conn.getRemoteAddress(buffer, offset, buffer.length - offset);
+ String realip = getHeader("X-Real-IP");
+
+ if (realip == null) {
+ int len = _conn.getRemoteAddress(buffer, offset, buffer.length -
offset);
+ return offset + len;
+ }
+
+ int len = realip.length();
+
+ for (int i = 0; i < len; i++)
+ buffer[offset + i] = (byte) realip.charAt(i);
return offset + len;
}
public String getRemoteHost()
{
- return _conn.getRemoteHost();
+ String realip = getHeader("X-Real-IP");
+
+ if (realip == null)
+ return _conn.getRemoteHost();
+
+ return realip;
}
/**
|