欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Nginx负载均衡配置

程序员文章站 2022-06-27 20:54:58
Nginx负载均衡配置项目gateway 在服务器2.10和2.11上nginx 默认是轮询的 weight=1 是权重分配 都是1表示平均分配upstream proejct1 { server 192.168.2.10:12000 weight=1; server 192.168.2.11:12000 weight=1; } server { listen 80; listen [::]:80...

Nginx负载均衡配置
项目gateway 在服务器2.10和2.11上
nginx 默认是轮询的 weight=1 是权重分配 都是1表示平均分配

upstream proejct1 {
       server 192.168.2.10:12000 weight=1;
       server 192.168.2.11:12000 weight=1;
    }

     server {
        listen       80;
        listen       [::]:80;
        server_name  _;
	    autoindex on;
        client_max_body_size 200m;
        access_log   /var/log/nginx/error.log main;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
	          root /data/runtime/proejct1/www;
            index index.html;
        }
        
       
        location ~* ^/(api) { 
            proxy_pass http://proejct1; 
            proxy_set_header Host $host; 
            proxy_connect_timeout 15s; 
            proxy_send_timeout 15s; 
            proxy_read_timeout 15s; 
            proxy_set_header X-Real-IP $remote_addr; 
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
        }       

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
     }

本文地址:https://blog.csdn.net/qq_36567996/article/details/107340865

相关标签: Nginx