nginx 代理配置 多个服务配置 socke配置

博客围绕Nginx展开,主要涉及多服务配置以及Socket配置相关内容,在信息技术领域,Nginx配置对于后端服务的稳定运行至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

user root;
worker_processes  1;

events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen   80;
        location  / {
            root  /home/html/www/dist;
            index  login.html index.html;
        }
	location ^~ /im_client { 
            root   /home/html/www/dist;
            index im_client.html;
	    try_files $uri $uri/ /im_client.html;
        }
	location ^~ /vi/css/apiChart {   //代理
            proxy_pass  http://172.****;
	    rewrite /v1/css/apiChart / break;  //代理删除baseurl
        }
        location ^~ /v1/ccs {
            proxy_pass http://172.*****;
            client_max_body_size 100m;	
        }

	location ^~ /p_socket {  //socket链接的配置
          proxy_pass  http://172.****;
	    proxy_http_version 1.1; 
	    proxy_set_header Upgrade $http_upgrade;
	    proxy_set_header Connection "upgrade";
        }
    }
    server {  //多个服务
        listen 8888;
        location / {
            root  /home/p_sdk;
            index  index.html;
        }
    }

}

worker_processes  2;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    upstream pigeon {
	ip_hash;
        server 172.16.41**:8008;
        #server 172.16.40.**:8008;
    }

    upstream socket {
        ip_hash;
        server 172.16**:3001;
        #server 172.16.4**.220:3001;
    }


    server {
        listen 80;
        location / {
            proxy_pass http://pigeon;
        }

	location ^~ /_socket {
            proxy_pass   http://socket;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }

    server {
        listen 8008;
        location  / {
            root  /home
            index index.html;
            try_files $uri $uri/ /index.html;
        }

    	location ^~ /it {
            root   /home;
            index index.html;
    	    try_files $uri $uri/ index.html;
        }

        location ^~ /_api {
            proxy_pass  http://***:807/;
        }
    }

    server {
        listen 8888;
        location / {
            root  /home;
            index  index.html;
        }
    }

   server {
        listen 9999;
        location / {
            root  /home;
            index  index.html;
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值