系统相关
首页 > 系统相关> > centos8+nginx1.17+tomcat9集群

centos8+nginx1.17+tomcat9集群

作者:互联网

centos8+nginx1.17+tomcat9集群

1.我们这里准备3台 tomcat,端口分别是8081、8082、8083,针对同个域名,每次用 Nginx实现不同的转发,分别在每个 tomcat的 webapps目录下创建ROOT目录,并创 index. htm,分别在html的body里标记1/2/3以示区分
2.修改tomct的webapp/root下的index.jsp文件区分不同的tomcat
3.安装nginx并指定安装目录
4.在浏览器中输入ip[http://192.168.2.128/](http://192.168.2.128/)地址
快速启动配置项目
./tomcat1/bin/startup.sh
./tomcat2/bin/startup.sh
./tomcat3/bin/startup.sh
./nginx/sbin/nginx
快速关闭配置项
./tomcat1/bin/shutdown.sh
./tomcat2/bin/shutdown.sh
./tomcat3/bin/shutdown.sh
./nginx/sbin/nginx -s stop
nginx的配置文件
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


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"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

      upstream clustertomcat{
        server 192.168.2.128:8081 weight=2;
        server 192.168.2.128:8082 weight=1;
        server 192.168.2.128:8083 weight=1;
        }

    server {
        listen       80;
        server_name  localhost;
        location / {
            proxy_pass http://clustertomcat;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }  
}

标签:nginx1.17,bin,http,log,nginx,sh,error,tomcat9,centos8
来源: https://www.cnblogs.com/khtt/p/15233573.html