[squid-users] Squid, Tomcat and SESSIONID

From: Rejaine Monteiro <rejaine_at_bhz.jamef.com.br>
Date: Thu, 11 Aug 2011 09:18:52 -0300

Hi list,

I'm having problems with squid (v3) and tomcat with caching of
session_id/cookie generate on a URL
ps: sorry about long post and poor english ;0(

This is my squid.conf
################# SQUID.CONF (testing configuration)
http_port 3128

hierarchy_stoplist cgi-bin \?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache deny QUERY

acl JSESSIONID1 req_header Cookie -i JSESSIONID
cache deny JSESSIONID1
acl JSESSIONID2 rep_header Set-Cookie -i JSESSIONID
cache deny JSESSIONID2

refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 ignore-no-cache
ignore-no-store override-expire
refresh_pattern -i mysite 0 0% 0 ignore-no-cache
ignore-no-store override-expire
refresh_pattern . 0 20% 4320

cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
debug_options ALL,1 33,2
acl all src 0.0.0.0
acl localhost src 127.0.0.1
cache_effective_user squid
cache_effective_group nogroup
logfile_rotate 0
http_access allow all
#######################################

I'm using de CURL (command line) on Linux to this test...

When access mysite (http://mysite.com.br:8080/app) on the frist time
(this is a Tomcat aplication, without any Apache on midleware) , the
jsessionid code (Location) is equal to cookie (Set-Cookie)

# curl -x localhost:3128 -I http://mysession:8080/app
HTTP/1.0 302 Moved Temporarily
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=950D366F1F13A7BA226E89C928060BAF.node1; Path=/app
Expires: 15 Aug 2011 21:53:52 GMT
Cache-Control: max-age=120
Location:
http://mysite/session.do;jsessionid=950D366F1F13A7BA226E89C928060BAF.node1?app=portal
Content-Type: text/html;charset=utf-8
Content-Length: 0
Date: Wed, 10 Aug 2011 21:53:52 GMT
X-Cache: MISS from localhost
X-Cache-Lookup: HIT from localhost:3128
Via: 1.0 localhost (squid/3.0.STABLE18)
Proxy-Connection: keep-alive

But on second acess, the session is cached (because max-age=120
parameter) This was not expected because the sessioind should change for
each session (this is a dynamic page). See bellow:

# curl -x localhost:3128 -I
HTTP/1.0 302 Moved Temporarily
Server: Apache-Coyote/1.1
Expires: 15 Aug 2011 21:53:52 GMT
Cache-Control: max-age=120
Location:
http://mysite/app/session.do;jsessionid=950D366F1F13A7BA226E89C928060BAF.node1?app=portal
Content-Type: text/html;charset=utf-8
Content-Length: 0
Date: Wed, 10 Aug 2011 21:53:52 GMT
Age: 1
X-Cache: HIT from localhost
X-Cache-Lookup: HIT from localhost:3128
Via: 1.0 localhost (squid/3.0.STABLE18)
Proxy-Connection: keep-alive

With other proxy servers, this problem does not occur (I already tested
with the Freeproxy and AnalogX and the result of jessession is always
different from the previous session, even with max-age parameter)
therefore, I believe that the problem occurs only when using the
proxy-squid.

# curl -x freeproxyserver:8080 -I http://mysession:8080/app
HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=59F7E0C6E68988FC54DCD0C7F7902933.node1; Path=/app
Expires: 15 Aug 2011 22:03:27 GMT
Cache-Control: max-age=120
Location:
http://mysite:8080/session.do;jsessionid=59F7E0C6E68988FC54DCD0C7F7902933.node1?app=portal
Content-Type: text/html;charset=utf-8
Content-Length: 0
Date: Wed, 10 Aug 2011 22:03:27 GMT

I don't have access to modify the Cache-Control in the web application
and as in other proxy-server does not occur the error, I have to solve
this issue in Squid.

I already tried to enter the settings below, but not relieving effect
to. The only solution that worked was set cache_deny for the entire
site, but this is not desirable (for reasons of bandwidth consumption)

##E# I tried this configuration (but not effect)
hierarchy_stoplist cgi-bin \?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache deny QUERY
acl JSESSIONID1 req_header Cookie -i JSESSIONID
cache deny JSESSIONID1
acl JSESSIONID2 rep_header Set-Cookie -i JSESSIONID
cache deny JSESSIONID2
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 ignore-no-cache
ignore-no-store override-expire
refresh_pattern -i mysite 0 0% 0 ignore-no-cache
ignore-no-store override-expire
refresh_pattern . 0 20% 4320
#####

I appreciate any help
Received on Thu Aug 11 2011 - 12:18:57 MDT

This archive was generated by hypermail 2.2.0 : Thu Aug 11 2011 - 12:00:01 MDT