zoukankan      html  css  js  c++  java
  • 【Nginx】nginx 代理 Haproxy 怎么设置?

    由于Haproxy是通过 url 正则匹配 识别 的,nginx代理到 haproxy需要设置 

    proxy_set_header Host 为 haproxy的目标 url

    直接上配置

    upstream xxx03_api_haproxy {
        server xxx03.api.xxx.com;
    }
    upstream xxx03_443_api_haproxy {
        server xxx03.api.xxx.com:443;
    }
    
    server {
       listen 80;
       #server_name xxx03.api.xxx.com;
       location / {
               proxy_pass http://xxx03_api_haproxy;
               proxy_set_header Host xxx03.api.xxx.com;
               proxy_redirect off;
       }
    }
    
    #server {
    #   listen 80;
    #   server_name xxx03.test.xxx.com;
    #   location / {
    #           proxy_pass https://xxx03_443_api_haproxy;
    #           proxy_set_header Host xxx03.test.xxx.com;
    #           proxy_redirect off;
    #   }
    #}
    
    server {
        listen 443;
        #server_name xxx03.test.xxx.com;
        ssl on;
        ssl_certificate /etc/nginx/conf.d/server.cert;
        ssl_certificate_key /etc/nginx/conf.d/server.key;
        location / {
               proxy_pass https://xxx03_443_api_haproxy;
               proxy_set_header Host xxx03.test.xxx.com;
               proxy_redirect off;
       }
    }
  • 相关阅读:
    Spring boot 梳理
    Spring boot 梳理
    Spring boot 梳理
    观察者模式
    设计模式原则
    Spring MVC上传文件
    Spring MVC视图解析器
    Spring MVC中Action使用总结
    Spring MVC控制器
    Java并发 两个线程交替执行和死锁
  • 原文地址:https://www.cnblogs.com/junneyang/p/6110760.html
Copyright © 2011-2022 走看看