Score:0

HAProxy path_beg error - 503 service unavailable

us flag
SoT

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

On another host, I install and config 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

After that I use curl to test my haproxy:

curl --location --request GET "http://localhost/api/authorization/oauth/sign-key"

I expect that this request will be route to:

http://172.18.1.125:8888/oauth/sign-key

But I got 503 error instead:

<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>

What am I wrong or missing?

Score:1
in flag

im guessing you are going to http://172.18.1.125:8888/api/authorization/oauth/sign-key instead of 172.18.1.125:8888/oauth/sign-key like you expect cause you are doing nothing to strip out 'api/authorization' ... try this backend:

backend be_auth
    http-request set-path %[path,regsub(^/api/authorization/,/)]
    server s1 172.18.1.125:8888
SoT avatar
us flag
SoT
Thanks, it works
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.