美文网首页
nginx负载均衡配置

nginx负载均衡配置

作者: 庄宁文 | 来源:发表于2017-02-22 10:06 被阅读0次

    http

    nginx.conf:

    worker_processes  1;

    events {

    worker_connections  1024;

    }

    http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    upstream backend {

    #ip_hash;

    server 192.168.1.251;

    server 192.168.1.252;

    server 192.168.1.247;

    }

    server {

    listen       80;

    server_name  2;

    location / {

    #设置主机头和客户端真实地址,以便服务器获取客户端真实IP

    proxy_set_header Host $host;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    #禁用缓存

    proxy_buffering off;

    #反向代理的地址

    proxy_pass http://backend;

    }

    }

    }

    TCP

    stream{

    server{

    listen1034;

    proxy_passapp;

    }

    upstreamapp{

    server192.168.0.3:1034;

    server192.168.0.4:1034;

    server192.168.0.6:1034;

    }

    }

    相关文章

      网友评论

          本文标题:nginx负载均衡配置

          本文链接:https://www.haomeiwen.com/subject/dzbpwttx.html