Linux
HAProxy path_beg 錯誤 - 503 服務不可用
給定一個執行的後端:
172.18.1.125:8888
捲曲測試:
curl --location --request GET "http://172.18.1.125:8888/oauth/sign-key" sample_response //>> HERE IS RESPONSE
在另一台主機上,我安裝和配置 haproxy:
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
之後我使用 curl 來測試我的 haproxy:
curl --location --request GET "http://localhost/api/authorization/oauth/sign-key"
我希望這個請求將被路由到:
http://172.18.1.125:8888/oauth/sign-key
但我得到了 503 錯誤:
<html><body><h1>503 Service Unavailable</h1> No server is available to handle this request. </body></html>
我錯了或錯過了什麼?
我猜你會像你期望的那樣去http://172.18.1.125:8888/api/authorization/oauth/sign-key而不是 172.18.1.125:8888/oauth/sign-key 因為你沒有做任何事情來剝離’ api/authorization’ …試試這個後端:
backend be_auth http-request set-path %[path,regsub(^/api/authorization/,/)] server s1 172.18.1.125:8888