Skip to content

Why using the same upstream twice w/ different auth methods does not work? #11942

Answered by mikyll
plamenlakov asked this question in Q&A
Discussion options

You must be logged in to vote

changed the uri to /* and it DID work, but obviously I'd like a prefix :D

To achieve what you described (and I think I understood 😄), you'll need to use proxy-rewrite plugin, to remove the prefix before forwarding the request to the upstream.

Here's an example with your configuration:

upstreams:
  - name: backend-api-upstream
    id: 1
    type: roundrobin
    nodes:
      - host: 172.17.0.1
        port: 3000
        weight: 1

routes:
  - uri: /public/*
    upstream_id: 1
    plugins:
      # This plugin will remove the prefix "/public"
      proxy-rewrite:
        regex_uri:
          - ^/public/(.*)
          - /$1

  - uri: /api/*
    upstream_id: 1
    plugins:
      # Uncomment t…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@plamenlakov
Comment options

@dosubot
Comment options

Comment options

You must be logged in to vote
1 reply
@plamenlakov
Comment options

Answer selected by plamenlakov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants