Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header X-Forwarded-Prefix not sent when proxying an API #5602

Closed
erikgb opened this issue Feb 24, 2020 · 6 comments
Closed

Header X-Forwarded-Prefix not sent when proxying an API #5602

erikgb opened this issue Feb 24, 2020 · 6 comments

Comments

@erikgb
Copy link

erikgb commented Feb 24, 2020

Summary

I would expect Kong to set the X-Forwarded-Prefix header when proxying an API. This was registered as issue #1150 and fixed with PR #1180. But it seems like X-Forwarded-Prefix part of this fix has been lost (or removed).

I notice the following constant in the code, but it seems unused:

FORWARDED_PREFIX = "X-Forwarded-Prefix",

Steps To Reproduce

  1. Set up an echo route (DB-Less configuration)
services:
  - name: echo
    url: https://postman-echo.com/get
    routes:
      - name: echo
        paths:
          - /echo
  1. Perform a HTTP GET request through Kong

Expected behavior

The X-Forwarded-Prefix header is echoed with the value /echo.

Actual behavior

No X-Forwarded-Prefix header in the echo response

Additional Details & Logs

  • Kong version 1.5.1
@erikgb
Copy link
Author

erikgb commented Feb 24, 2020

Adding Request Transformer Plugin configuration for the service(s) is a possible workaround:

plugins:
  - name: request-transformer
    service: echo
    config:
      add:
        headers:
          - x-forwarded-prefix:/echo

But I would love to not have this additional configuration....

@bungle
Copy link
Member

bungle commented Feb 27, 2020

Yes, currently we only do:

X-Forwarded-For
X-Forwarded-Port
X-Forwarded-Proto
X-Forwarded-Host
X-Real-IP

We don't currently support:

X-Forwarded-Prefix
X-Forwarded-By
X-Forwarded-Server
X-Forwarded-SSL
X-Proxied-Https

Out of those that we don't have, I think adding X-Forwarded-Prefix makes most sense.

bungle added a commit that referenced this issue Feb 27, 2020
### Summary

Kong currently adds these headers to upstream request:
```
X-Forwarded-For
X-Forwarded-Port
X-Forwarded-Proto
X-Forwarded-Host
X-Real-IP
```

@erikgb mentioned that he would like to have `X-Forwarded-Prefix`
added on #5602.

This PR adds that, and additionally introduces a new PDK function:
```lua
local path = kong.request.get_forwarded_path()
```

### Issues Resolved

Close #5602
@bungle
Copy link
Member

bungle commented Feb 27, 2020

@erikgb, there is now a PR #5620, any feedback is welcomed!

bungle added a commit that referenced this issue Feb 27, 2020
### Summary

Kong currently adds these headers to upstream request:
```
X-Forwarded-For
X-Forwarded-Port
X-Forwarded-Proto
X-Forwarded-Host
X-Real-IP
```

@erikgb mentioned that he would like to have `X-Forwarded-Prefix`
added on #5602.

This PR adds that, and additionally introduces a new PDK function:
```lua
local path = kong.request.get_forwarded_path()
```

### Issues Resolved

Close #5602
bungle added a commit that referenced this issue Feb 28, 2020
### Summary

Kong currently adds these headers to upstream request:
```
X-Forwarded-For
X-Forwarded-Port
X-Forwarded-Proto
X-Forwarded-Host
X-Real-IP
```

@erikgb mentioned that he would like to have `X-Forwarded-Prefix`
added on #5602.

This PR adds that, and additionally introduces a new PDK function:
```lua
local path = kong.request.get_forwarded_path()
```

### Issues Resolved

Close #5602
bungle added a commit that referenced this issue Mar 10, 2020
### Summary

Kong currently adds these headers to upstream request:
```
X-Forwarded-For
X-Forwarded-Port
X-Forwarded-Proto
X-Forwarded-Host
X-Real-IP
```

@erikgb mentioned that he would like to have `X-Forwarded-Prefix`
added on #5602.

This PR adds that, and additionally introduces a new PDK function:
```lua
local path = kong.request.get_forwarded_path()
```

### Issues Resolved

Close #5602
bungle added a commit that referenced this issue Mar 11, 2020
### Summary

Kong currently adds these headers to upstream request:
```
X-Forwarded-For
X-Forwarded-Port
X-Forwarded-Proto
X-Forwarded-Host
X-Real-IP
```

@erikgb mentioned that he would like to have `X-Forwarded-Prefix`
added on #5602.

This PR adds that, and additionally introduces a new PDK function:
```lua
local path = kong.request.get_forwarded_path()
```

### Issues Resolved

Close #5602
@bungle bungle closed this as completed Mar 11, 2020
@adil-bouchaara
Copy link

@erikgb can you please tell me which configuration you are using for kong ?

@erikgb
Copy link
Author

erikgb commented May 26, 2020

@erikgb can you please tell me which configuration you are using for kong ?

I am not sure what you are asking for, but we are using DB-less configuration, and as a workaround before Kong 2.1 (with this issue resolved) we have been using the configuration as described in #5602 (comment)

@adil-bouchaara
Copy link

I found one https://github.com/hbagdi/deck
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants