Score:0

Change request without change url on browser HAProxy

nz flag

i configure haproxy, when i type test.example.com it redirect me to example.com/test

This is what i want but the problem i want this happen without changing the url on the browser, i want it to keep test.example.com but send request to example.com/test

Here is my haproxy.cfg

**frontend tt bind *:80 bind *:443 mode http default_backend ss bind :443 ssl crt /etc/ssl/certs/ssl.pem

 http-request redirect scheme https unless { ssl_fc } 

backend ss mode http balance roundrobin option forwardfor

http-request set-header X-Forwarded-Port %[dst_port] http-request add-header X-Forwarded-Proto https if { ssl_fc } http-request set-var(req.rewrite_example) req.hdr(host),lower,regsub(.example.com$,) if { hdr_end(host) -i .example.com } http-request set-path /%[var(req.rewrite_example)] if { var(req.rewrite_example) -m found }

http-request set-header Host example.com if { var(req.rewrite_example) -m found } option httpchk HEAD / HTTP/1.1rnHost:localhost

server web1 example.com:80

**

Score:0
cn flag

Your configuration is almost working, please check the below few changes:

# ## example_fe ##
frontend example_fe
    bind *:80 
    bind *:443 ssl crt /etc/ssl/certs/ssl.pem
    http-request redirect scheme https unless { ssl_fc } 
    mode http 
    default_backend example_be
# ## example_be ##
backend example_be
    mode http 
    balance roundrobin 
    option forwardfor
    http-request set-header X-Forwarded-Port %[dst_port] 
    http-request add-header X-Forwarded-Proto https if { ssl_fc } 
    http-request set-var(req.rewrite_example) req.hdr(host),lower,regsub(\.example\.com$,) if { hdr_end(host) -i .example.com } 
    http-request set-path /%[var(req.rewrite_example)]%[path] if { var(req.rewrite_example) -m found }
    http-request set-header Host example.com if { var(req.rewrite_example) -m found } 
    server web1 172.17.1.1:80
     

I have tested it on HAProxy version 2.4 and it works just fine. The above config is driven from Michael: https://serverfault.com/a/815668/372988

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.