'HAProxy how to substring path
Given a backend that running on:
172.18.1.125:8888
curl tested:
curl --location --request GET "http://172.18.1.125:8888/oauth/sign-key"
sample_response //>> HERE IS RESPONSE
I want to config a rule to transform
http://172.18.1.125/api/authorization/oauth/sign-key
to
http://172.18.1.125:8888/oauth/sign-key
Here is my haproxy config:
global
log /dev/log local0
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
debug
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
ssl-default-bind-ciphers PROFILE=SYSTEM
ssl-default-server-ciphers PROFILE=SYSTEM
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
frontend api_gateway
bind :80
acl PATH_auth path_beg /api/authorization/
use_backend be_auth if PATH_auth
backend be_auth
server s1 172.18.1.125:8888
http-request set-header Host 172.18.1.125
After that I use curl to test my haproxy:
curl --location --request GET "http://172.18.1.125/api/authorization/oauth/sign-key"
I expect that this request will be route to:
http://172.18.1.125:8888/oauth/sign-key
But seems that it route to
http://172.18.1.125:8888/api/authorization/oauth/sign-key
I don't know how to remove /api/authorization from the path. Any answer would be appreciate
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|