You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "deekshith-hadil (via GitHub)" <gi...@apache.org> on 2025/11/01 17:33:59 UTC
[I] help request: How to Set `X-Forwarded-Host` and `X-Forwarded-Port` in APISIX When Using a Second Proxy? [apisix]
deekshith-hadil opened a new issue, #12721:
URL: https://github.com/apache/apisix/issues/12721
### Description
I have a scenario where APISIX acts as the primary proxy for most users. However, in certain cases, some users access our services via a second proxy, which then forwards the request to APISIX. The architecture is illustrated below:
```mermaid
flowchart LR
subgraph User Side
User1["User"]
User2["User (via 2nd Proxy)"]
end
subgraph Front Proxy
FrontProxy["Proxy #2"]
end
subgraph APISIX Layer
APISIX["APISIX (Proxy)"]
end
subgraph Backend
HTTPPod["HTTP Pod"]
end
User1 -- HTTP Request --> APISIX
User2 -- HTTP Request --> FrontProxy
FrontProxy -- Forwards Request --> APISIX
APISIX -- Proxies Request --> HTTPPod
```
**Problem:**
When a request comes via Proxy #2, I want APISIX to identify and set the `X-Forwarded-Host` and `X-Forwarded-Port` headers to the values from Proxy #2, rather than its own (APISIX pod) host and port.
I understand that a custom plugin could potentially achieve this, but so far, APISIX does **not** override `X-Forwarded-Host` and `X-Forwarded-Port` as expected—it continues to set them to APISIX's own host and port.
### What I've Tried
- **proxy-rewrite plugin**
- **serverless-pre-function plugin**
- **serverless-post-function plugin**
I've followed the discussions and suggestions in the threads below, but none of these solutions have worked for me:
- [apache/apisix/issues/11974](https://github.com/apache/apisix/issues/11974)
- [apache/apisix/pull/8226](https://github.com/apache/apisix/pull/8226)
- [apache/apisix/issues/9530](https://github.com/apache/apisix/issues/9530)
- [apache/apisix/discussions/5091](https://github.com/apache/apisix/discussions/5091)
- [apache/apisix/issues/11580](https://github.com/apache/apisix/issues/11580)
---
**Questions:**
- Is there a recommended way to have APISIX set or override `X-Forwarded-Host` and `X-Forwarded-Port` when requests are forwarded by another proxy?
- Is this currently supported by APISIX, or is it a known limitation?
- Are there any workarounds or plugins I might have missed?
Any guidance or suggestions would be greatly appreciated!
### Environment
- APISIX version (run `apisix version`):
- Operating system (run `uname -a`):
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
- etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] help request: How to Set `X-Forwarded-Host` and `X-Forwarded-Port` in APISIX When Using a Second Proxy? [apisix]
Posted by "deekshith-hadil (via GitHub)" <gi...@apache.org>.
deekshith-hadil commented on issue #12721:
URL: https://github.com/apache/apisix/issues/12721#issuecomment-3482992320
APISIX will only alter X-Forwarded-Host and X-Forwarded-Port for requests originating from addresses configured in trusted_addresses. Add the relevant addresses to trusted_addresses in apisix's config.yaml to allow header modification. See the implementing PR: https://github.com/apache/apisix/pull/12551
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] help request: How to Set `X-Forwarded-Host` and `X-Forwarded-Port` in APISIX When Using a Second Proxy? [apisix]
Posted by "deekshith-hadil (via GitHub)" <gi...@apache.org>.
deekshith-hadil closed issue #12721: help request: How to Set `X-Forwarded-Host` and `X-Forwarded-Port` in APISIX When Using a Second Proxy?
URL: https://github.com/apache/apisix/issues/12721
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org