一、环境准备

tomcat8+memcached session共享

时间同步(同步后确认各服务器时间是否一致,不一致需要修改一下时区)

关闭防火墙

软件包和jar包链接:https://pan.baidu.com/s/1sl9Nob7

 

二、安装配置nginx和memcached

Nginx和memcached使用yum安装即可,下面是nginx配置文件内容

user  nginx;
worker_processes  1;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    sendfile        on;
    tcp_nopush     on;
    keepalive_timeout  65;
    gzip  on;
    upstream tomcat-web {
      server 192.168.0.14:8080;
      server 192.168.0.15:8080;
       }
    server {
        listen       80;
        server_name  www.tomcat.com;


        location / {
            root   html;
            index  index.html index.htm index.jsp;
        }
        location ~* \.(jsp|do)$ {
                proxy_pass http://tomcat-web;
                proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
                   }
       location /nginx_status {
                stub_status on;
                access_log off;
                allow 192.168.0.0/24;
                deny all;
                }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
                                                
nginx.conf

相关文章: