zhouer 发表于 2016-12-25 10:08:53

nginx memcache tomcat7 配置

kryo-1.03.jar
kryo-1.03-sources.jar
minlog-1.2.jar
reflectasm-0.9.jar
memcached-session-manager-1.6.3.jar
memcached-session-manager-tc7-1.6.3.jar
msm-kryo-serializer-1.6.3.jar
msm-javolution-serializer-1.6.3.jar
msm-xstream-serializer-1.6.3.jar
msm-flexjson-serializer-1.6.3.jar
javolution-5.4.3.1.jar
spymemcached-2.8.4.jar

conf/context.xml
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context path="" docBase="ROOT">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<!-- Uncomment this to enable Comet connection tacking (provides events
on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
sticky = "false"   
memcachedNodes="n1:10.10.55.135:11211"   
requestUriIgnorePattern=".*\.(png|gif|jpg|css|js)$"   
sessionBackupAsync="false"   
sessionBackupTimeout="100"   
transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"   
copyCollectionsForSerialization="false"   
/>
</Context>


\conf\nginx.conf
#usernobody;
worker_processes1;
#error_loglogs/error.log;
#error_loglogs/error.lognotice;
#error_loglogs/error.loginfo;
#pid      logs/nginx.pid;

events {
worker_connections1024;
}

http {
include       mime.types;
default_typeapplication/octet-stream;
#log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';
#access_loglogs/access.logmain;
sendfile      on;
#tcp_nopush   on;
#keepalive_timeout0;
keepalive_timeout65;
#gzipon;
upstream tomcats {
#ip_hash;
server 10.10.55.174:8080 weight=1;
server 10.10.55.135:8080 weight=10;
}
server {         
listen       80;         
server_name127.0.0.1;         
charset utf-8;         
location / {            
root   html;            
indexindex.html index.htm;            
proxy_pass      http://tomcats;            
proxy_set_headerX-Real-IP$remote_addr;            
client_max_body_size100m;         
}         
location ~ ^/(WEB-INF)/ {      
deny all;         
}         
error_page   500 502 503 504/50x.html;         
location = /50x.html {            
root   html;         
}      
}


server {
listen       80;
server_namelocalhost;
#charset koi8-r;
access_loglogs/host.access.logcombined;
location / {
root   html;
indexindex.html index.htm;
}
#error_page404            /404.html;
# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504/50x.html;
location = /50x.html {
root   html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#    proxy_pass   http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#    root         html;
#    fastcgi_pass   127.0.0.1:9000;
#    fastcgi_indexindex.php;
#    fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;
#    include      fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#    denyall;
#}
}

# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_namesomenamealiasanother.alias;
#    location / {
#      root   html;
#      indexindex.html index.htm;
#    }
#}

# HTTPS server
#
#server {
#    listen       443;
#    server_namelocalhost;
#    ssl                  on;
#    ssl_certificate      cert.pem;
#    ssl_certificate_keycert.key;
#    ssl_session_timeout5m;
#    ssl_protocolsSSLv2 SSLv3 TLSv1;
#    ssl_ciphersHIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers   on;
#    location / {
#      root   html;
#      indexindex.html index.htm;
#    }
#}
}


test.jsp
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<%=session.getId() %><br/>
<%=request.getServerName() %><br/>
<%=request.getServerPort() %><br/>
<%out.print("111111111111"); %><br/>
</body>
</html>
页: [1]
查看完整版本: nginx memcache tomcat7 配置