首页 > 其他 > 详细

Nginx、haproxy反向代理设置

时间:2017-04-01 13:29:44      阅读:163      评论:0      收藏:0      [点我收藏+]

Nginx反向代理配置:

#user  nobody;
worker_processes  1;

events {
    worker_connections  1024;
}


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


upstream lingyu.com { 
      server  192.168.1.102; 
      server  192.168.1.104;
      #ip_hash; 
} 
    server {
        listen       800;
        server_name  localhost;
  
        location / {
             proxy_pass http://lingyu.com;
             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_set_header   Cookie $http_cookie;
        }
    }
}

haproxy反向代理设置:

 

global
     daemon 
     maxconn 25600
 defaults
     mode http 
     timeout connect 5000ms 
     timeout client 50000ms 
     timeout server 50000ms
 frontend http-in
     bind *:800 
     default_backend servers
 backend servers
     balance     roundrobin #负载均衡模式轮询
     server server1 192.168.1.102:80 cookie A check
     server server2 192.168.1.104:80 cookie B check

写入Cookies时带上Domain就可以互相识别。

 

Nginx、haproxy反向代理设置

原文:http://www.cnblogs.com/madyina/p/6655543.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!