zoukankan      html  css  js  c++  java
  • linux环境下nginx + tomcat 负载均衡

    修改nginx 的配置文件/etc/nginx/nginx.conf

    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;
    
        # 负载均衡模块,负责网站的负载均衡功能和节点的健康检查
        # 实例中127.0.0.1:8080和8081分别是两个tomcat的ip地址和访问端口号
        upstream myservers{
               server 127.0.0.1:8080 weight=1;
               server 127.0.0.1:8081 weight=1;
        }
        server {
            listen       80 default_server;
            listen       [::]:80 default_server;
            server_name  _;
            root         /usr/share/nginx/html;
    
            # Load configuration files for the default server block.
            include /etc/nginx/default.d/*.conf;
    
            location / {
            	# 请求转发模块,将请求转发到指定的服务器上
                    proxy_pass http://myservers;
            }
    
            error_page 404 /404.html;
                location = /40x.html {
            }
    
            error_page 500 502 503 504 /50x.html;
                location = /50x.html {
            }
            
        }
    

    修改tomcat的访问端口: ./conf/server.xml

    将其中一个tomcat的以下两个端口分别该为:8006,8081,另一个tomcat的配置文件使用默认值,即仍是

    <Server port="8005" shutdown="SHUTDOWN">
        
    <Connector port="8081" protocol="HTTP/1.1"
       .../>
    

    https://www.cnblogs.com/xiaowenshu/p/10099119.html

  • 相关阅读:
    HAOI2015 树上染色
    HAOI2010 软件安装
    T2 Func<in T1,out T2>(T1 arg)
    事无巨细
    LitJson JavaScriptSerializer
    数据库操作
    jQuery:总体掌握
    sql一个题的解法分析讲解
    Javascript系列:总体理解
    c#
  • 原文地址:https://www.cnblogs.com/fyusac/p/13159542.html
Copyright © 2011-2022 走看看