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

  • 相关阅读:
    sublime去除空白行和重复行
    python list删除数据 和复制 列表
    微博实现简繁体转换
    2017.10.27日面试总结
    python 类和__class__理解
    python 单例模式应用
    pt-query-digest 慢日志监控
    在线安全清空慢查询日志slowlog
    Linux高级系统恢复技术
    灾备演练
  • 原文地址:https://www.cnblogs.com/fyusac/p/13159542.html
Copyright © 2011-2022 走看看