ngin常用配置

负载均衡

upstream WEB_SERVER {
    ip_hash;
    server 10.137.172.201;
    server 10.137.172.202;
    server 10.137.172.203;
}

location ~ ^/(.*)$ {
    proxy_pass     http://WEB_SERVER;
}

反向代理

upstream APP_SERVER {
    ip_hash;
    server 10.137.172.204:3000;
    server 10.137.172.205:3000;
}

location ~ ^/apps/(.*)$ {
    proxy_set_header x-real-ip $remote_addr;
    proxy_pass http://APP_SERVER/$1?$query_string;
}

socket.io

upstream SOCKET_SERVER {
    ip_hash;
    server 10.137.172.204:3001;
    server 10.137.172.205:3001;
}

location /socket.io/ {
    proxy_pass     http://SOCKET_SERVER$request_uri;
    proxy_redirect off;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_http_version    1.1;
}

关键字:Nginx

版权声明

本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处。如若内容有涉嫌抄袭侵权/违法违规/事实不符,请点击 举报 进行投诉反馈!

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部