Proxy_pass 相当于 HAProxy

Proxy_pass equivalent in HAProxy

什么是 Nginx pass_proxy HAProxy 中的这个

location /{
    proxy_pass https://WebApplication.azurewebsites.net;
  }

我尝试测试此配置,但当我指向具有以下配置的任何后端服务器时收到 404,但未在根目录上使用 ACL,例如使用自签名证书

    #---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    log /dev/log    local0
    log /dev/log    local1 notice
    user haproxy
    group haproxy
    maxconn  16000
    stats  socket /var/lib/haproxy/stats level admin
    tune.bufsize  32768
    tune.maxrewrite  1024
    tune.ssl.default-dh-param 2048
    daemon 
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
   log global
   mode http
   option httplog
   option dontlognull
   timeout connect 5000
   timeout client 50000
   timeout server 50000 
#---------------------------------------------------------------------
#HAProxy Monitoring Config
#---------------------------------------------------------------------
log global
   mode http
   option httplog
   option dontlognull
   timeout connect 5000
   timeout client 50000
   timeout server 50000
#---------------------------------------------------------------------
# FrontEnd Configuration
#---------------------------------------------------------------------
frontend fe_http_sne_in
bind *:443 ssl crt /etc/ssl/private/mydomain.pem
option forwardfor
default_backend be_default

backend be_default
mode http 
option forwardfor
http-request add-header X-Forwarded-For %[src]
server srv02 www.google.com:443 ssl verify none

指向任何使用 bing、google 作为 url 测试的后端服务器时,我收到 404 ...

我建议使用以下配置

frontend fe_http_sne_in
bind *:443 ssl crt /etc/ssl/private/mydomain.pem
option forwardfor
use_backend be_sne_insecure if { path_beg /test}
default_backend be_default

backend be_default
...

backend be_sne_insecure
mode http 
option forwardfor
http-request replace-header Host .* WebApplication.azurewebsites.net 
server srv01 WebApplication.azurewebsites.net:443 ssl verify none

在博客中post Introduction to HAProxy ACLs是解释的acl