1、nginx配置

# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf; events {
worker_connections 1024;
} http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048; include /etc/nginx/mime.types;
default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf; upstream api.xuetz.com {
server IP1:83 weight=1;
server IP2:83 weight=2;
} server {
listen 80 default_server;
listen [::]:80 default_server;
server_name api.xuetz.com;
root /usr/share/nginx/html; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location / {
rewrite ^(.*) https://XXX.com/$1 permanent;
# proxy_pass http://XXX.com;
# proxy_connect_timeout 1;
# proxy_send_timeout 1;
# proxy_read_timeout 1;
# proxy_set_header Host $http_host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
} # Settings for a TLS enabled server. server {
# listen 449 ssl http2 default_server;
# listen [::]:449 ssl http2 default_server;
listen 443 ssl;
server_name api.xuetz.com;
# ssl on;
root /usr/share/nginx/html; ssl_certificate "/etc/nginx/cert/***.com.pem";
ssl_certificate_key "/etc/nginx/cert/***.com.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location / {
proxy_pass http://XXX.com;
proxy_connect_timeout 1;
proxy_send_timeout 30;
proxy_read_timeout 30;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
} }

2、tomcat  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> <!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> <Resource
name="jdbc/xrh_core"
auth="Container"
type="javax.sql.DataSource"
description="MySQL 5.0"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://***/rds?useSSL=false"
username="xrh"
password="123456"
maxIdle="30"
maxWait="10000"
maxActive="100"/> <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:127.0.0.1:11211"
sticky="false"
sessionBackupAsync="false"
sessionBackupTimeout="1000"
lockingMode="auto"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"/>
</Context>

如应用系统有采用ueditor,则Manager 不能配置requestUriIgnorePattern=".*\.(png|gif|jpg|css|js)$" ,否则会出现session过期问题。

nginx + tomcat + memcached 做负载均衡及session同步的更多相关文章

  1. windows系统下nginx+tomcat+redis做负载均衡和session粘滞附整套解决方案

    Nginx: 在nginx-1.8.0\conf目录下找到nginx.conf文件,打开文件修改文件中http{}中的内容,在http{}中加入 upstream localhost  { serve ...

  2. Nginx+Tomcat8+Memcached实现负载均衡及session共享

    1> 基础环境 简易拓扑图: 2> 部署Tomcat [root@node01 ~]# ll -h ~ |egrep 'jdk|tomcat'-rw-r--r-- 1 root root ...

  3. keepalived+nginx+tomcat+redis实现负载均衡和session共享(原创)

    keepalived+nginx+tomcat+redis实现负载均衡和session共享 直接上链接,码了一天,就不再重写了,希望能帮到大家,有问题欢迎留言交流.

  4. tomcat结合nginx或apache做负载均衡及session绑定

    1.tomcat结合nginx做负载均衡,session绑定 nginx:192.168.223.136   tomcat:192.168.223.146:8081,192.168.223.146:8 ...

  5. nginx+tomcat集群负载均衡(实现session复制)

    转自:http://talangniao.iteye.com/blog/341512 架构描述 前端一台nginx服务器做负载均衡器,后端放N台tomcat组成集群处理服务,通过nginx转发到后面( ...

  6. Nginx+Tomcat+Memcache实现负载均衡及Session共享

    第一部分 环境介绍 部署环境: Host1:Nginx.Memcached.Tomcat1 Host2:Tomcat2 Tomcat_version:8.0.38 第二部分 Nginx+Tomcat实 ...

  7. 通过Nginx+tomcat+redis实现反向代理 、负载均衡及session同步

    一直对于负载均衡比较陌生,今天尝试着去了解了一下,并做了一个小的实验,对于这个概念有一些认识,在此做一个简单的总结 什么是负载均衡 负载均衡,英文 名称为Load Balance,指由多台服务器以对称 ...

  8. windows使用nginx+memcached实现负载均衡和session或者缓存共享

    windows使用nginx+memcached实现负载均衡和session或者缓存共享 两台server server1:115.29.186.215 windows2008 64位操作系统 ser ...

  9. Nginx+Tomcat+Redis实现负载均衡、资源分离、session共享

    Nginx+Tomcat+Redis实现负载均衡.资源分离.session共享 CentOS安装Nginx http://centoscn.com/CentosServer/www/2013/0910 ...

随机推荐

  1. Javascript的是三种字符串连接方式

    第一种:用连接符“+”连接字符串 str="a"; str+="b"; 这种方法相对以下两种,最便捷快速.建议100字符以下的连接使用这种连接方式. 第二种:以 ...

  2. k3 cloud中单据体中文本自适应

    在单据体中添加多行文本,然后设置本地配置,只读单元格自动换行

  3. css隐藏滚动条 兼容谷歌、火狐、IE等各个浏览器

    项目中,页面效果需要展示一个页面的移动端效果,使用的是一个苹果手机样式背景图,咋也没用过苹果,咋也不敢形容. 如下图所示: 在谷歌浏览器如图一滚动条顺利隐藏,但是火狐就如图二了,有了滚动条丑的一批. ...

  4. C#人民币金额大写转换

    人民币金额大小写转换,三行代码 //完善了一下查询到的方法,支持小数,保留2位小数 public string NumGetStr(double Num) { string[] DX_SZ = { & ...

  5. Linux学习--第三天--linux文件目录、ls、mkdir、mv、rm、touch、cat、tac、more、less、head、tail、ln、chmod、chown、chgrp、umask

    文件目录 目录名 备注 bin 下面的命令所有人都可以运行 sbin 只有root才能运行,s代表super /mnt,/media,/misc 都是挂载目录,但一般只用mnt /opt 第三方软件安 ...

  6. 为什么我选择用 flutter

    1. flutter 生成的是机器代码,他既不是 hybrid 也不是transpiler,  因此有很高的执行效率. 2. declarative ui,这不是什么新的概念,在 react vue ...

  7. 用selenium启动chrome浏览器

    python 3.7 pycharm 1.安装selenium pip3 install selenium 2.下载与chrome匹配的chromdriver.exe,放到项目的解释器路径下,跟pyt ...

  8. 原生JS 将时间转换成几秒前,几分钟前…常用于评论回复功能

    //格式化时间 留备用~ function getDateDiff(dateStr) { var publishTime = dateStr / 1000, d_seconds, d_minutes, ...

  9. 【Luogu4191】[CTSC2010] 性能优化

    题目链接 题意简述 求循环卷积意义下的 \(A(x)*B(x)^C\). 模数为 n+1 ,长度为 n. Sol 板子题. 循环卷积可直接把点值快速幂来解决. 所以问题就是要快速 \(DFT\),由于 ...

  10. 【UOJ#207】共价大爷游长沙

    题目链接 题目描述 火车司机出秦川,跳蚤国王下江南,共价大爷游长沙.每个周末,勤劳的共价大爷都会开车游历长沙市. 长沙市的交通线路可以抽象成为一个 \(n\) 个点 \(n−1\) 条边的无向图,点编 ...