最近要部署一个电商的服务器环境,主要涉及到的tomcat、nginx、redis的部署,我个人不是喜欢什么都往服务器上装,有些软件难以卸载干净,安装或是升级都会或多或少的残留一些东西,时间长了服务器会被一些不知道的东西占用资源。
docker run -p 80:80 --name nginx -d nginx
docker cp -a nginx:/etc/nginx/ /srv/nginx/conf
docker stop nginx
docker rm nginx
docker run -p 80:80 --restart always --name nginx -v /srv/nginx/www:/www -v /srv/nginx/conf/:/etc/nginx/ -v /srv/nginx/logs:/var/log/nginx -v /srv/nginx/wwwlogs:/wwwlogs -d nginx
docker inspect containerid
upstream projectname {
server 172.17.0.1:8080;
server 172.17.0.1:8081;
}
server {
listen 80;
server_name www.xxx.com;
#charset koi8-r;
access_log /var/log/nginx/host.access.log main;
location / {
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;
proxy_pass http://projectname;
rewrite "^/+$" /smoec/index.html redirect;
root /smoec/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
docker run -d -p 6379:6379 --name myredis registry.docker-cn.com/library/redis
<Manager className="org.redisson.tomcat.RedissonSessionManager"
configPath="${catalina.base}/conf/mySession.json" readMode="REDIS" updateMode="DEFAULT"/>
{
"singleServerConfig":{
"idleConnectionTimeout":10000,
"pingTimeout":1000,
"connectTimeout":10000,
"timeout":3000,
"retryAttempts":3,
"retryInterval":1500,
"reconnectionTimeout":3000,
"failedAttempts":3,
"subscriptionsPerConnection":5,
"clientName":null,
"address": "redis://172.18.0.3:6379",
"subscriptionConnectionMinimumIdleSize":1,
"subscriptionConnectionPoolSize":50,
"connectionMinimumIdleSize":32,
"connectionPoolSize":64,
"database":0
},
"threads":0,
"nettyThreads":0,
"codec":{
"class":"org.redisson.codec.JsonJacksonCodec"
},
"transportMode":"NIO"
}