Posted: Wed, Mar 9 01:17 AM (PST)
Do you need store your Tomcat sessions in database?
That is solution for you! Redis database is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
How do I use it?
Download, extract and compile Redis database with:
$ curl -O http://redis.googlecode.com/files/redis-2.2.2.tar.gz
$ tar xzf redis-2.2.2.tar.gz
$ cd redis-2.2.2
$ make
The binaries that are now compiled are available in the src directory. Run Redis with:
$ src/redis-server
You can interact with Redis using the built-in client:
$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
Our Redis database is ready.
Next step: download the latests build Redis Store for Tomcat at:
http://github.com/xetorthio/RedisStore/downloads
Copy jar into the lib folder of your tomcat installation directory, then edit conf/server.xml file and within your context tag add the following lines:
<Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="true" maxActiveSessions="1" minIdleSwap="1" maxIdleSwap="1" maxIdleBackup="1">
<Store className="org.apache.catalina.session.RedisStore"
host="localhost"
port="6379"
password="something"
database="0"
/>
</Manager>
Make sure that whatever you store in the session is Serializable.
Tags:
Posted: Tue, Mar 8 06:26 PM (PST)
You need to add proxy_intercept_errors on to nginx configuration.
listen 10.10.10.10:80;
server_name www.example.com;
location / {
proxy_pass http://127.0.0.1:8180;
proxy_set_header Host $host;
proxy_set_header Client-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_intercept_errors on;
}
location /images/ {
root /usr/local/apache-tomcat-6.0/webapps/ROOT/;
expires max;
}
location /css/ {
root /usr/local/apache-tomcat-6.0/webapps/ROOT/;
expires max;
}
location /js/ {
root /usr/local/apache-tomcat-6.0/webapps/ROOT/;
expires max;
}
error_page 500 502 503 504 404 = /404.html;
location /404.html {
rewrite ^ http://www.example.com/ permanent;
}
Tags: