Anass Kartit
Anass Kartit

Reputation: 2088

Proxy_pass equivalent in HAProxy

what is the equivalent of Nginx pass_proxy this in HAProxy

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

I tried to test this configuration but I receive 404 when I point to any backend server with the below configuration without using ACLs on root for example with self signed certificate

    #---------------------------------------------------------------------
# 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

I receive 404 when pointing to any backend server tested with bing, google as urls ...

enter image description here

Upvotes: 2

Views: 7987

Answers (1)

Aleksandar
Aleksandar

Reputation: 2672

I suggest to use the following config

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

In the Blog post Introduction to HAProxy ACLs is the acl explained

Upvotes: 6

Related Questions