apisix icon indicating copy to clipboard operation
apisix copied to clipboard

help request: whether apisix supports changing http host before the access phase ?

Open zuiyangqingzhou opened this issue 3 years ago • 5 comments
trafficstars

Description

Currently, I have configured the routing and forwarding rules in apisix just like:

host: api.test.com
path: /v1/verify

it works well. But the demand I received later is to add a lot of domain , and we have a lot of routing rules like this, it is impossible to change one by one.

so, in order to avoid the 404 problem of route matching, is it possible to change the host passed by http to a specified host like api.test.com before the access phase(or more accurately: before routes match)?

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):

zuiyangqingzhou avatar Aug 24 '22 07:08 zuiyangqingzhou

@zuiyangqingzhou Hi, you can add hosts attribute in service, https://apisix.apache.org/zh/blog/2021/09/29/release-apache-apisix-2.10/#%E6%96%B0%E5%8A%9F%E8%83%BDservice-%E5%A2%9E%E5%8A%A0-hosts-%E5%B1%9E%E6%80%A7

Hazel6869 avatar Aug 24 '22 08:08 Hazel6869

@zuiyangqingzhou Hi, you can add hosts attribute in service, https://apisix.apache.org/zh/blog/2021/09/29/release-apache-apisix-2.10/#%E6%96%B0%E5%8A%9F%E8%83%BDservice-%E5%A2%9E%E5%8A%A0-hosts-%E5%B1%9E%E6%80%A7

Thanks for your reply, but this should not meet my requirements, I need to change the host before route matching occurs.

zuiyangqingzhou avatar Aug 24 '22 09:08 zuiyangqingzhou

it works well. But the demand I received later is to add a lot of domain , and we have a lot of routing rules like this, it is impossible to change one by one.

Jump from yourself option. The root problem is you have to change a lot of hosts in every routes. So try to put the hosts field to the service object and bind routes to it.

tokers avatar Aug 24 '22 09:08 tokers

it works well. But the demand I received later is to add a lot of domain , and we have a lot of routing rules like this, it is impossible to change one by one.

Jump from yourself option. The root problem is you have to change a lot of hosts in every routes. So try to put the hosts field to the service object and bind routes to it.

However, we did a lot of custom development, and the service object was weakened in our system.

Is there any other way to change the host before the route matches?

zuiyangqingzhou avatar Aug 24 '22 12:08 zuiyangqingzhou

it works well. But the demand I received later is to add a lot of domain , and we have a lot of routing rules like this, it is impossible to change one by one.

Jump from yourself option. The root problem is you have to change a lot of hosts in every routes. So try to put the hosts field to the service object and bind routes to it.

However, we did a lot of custom development, and the service object was weakened in our system.

Is there any other way to change the host before the route matches?

Inject your own Nginx directives.

tokers avatar Aug 25 '22 01:08 tokers

This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Aug 29 '23 10:08 github-actions[bot]

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.

github-actions[bot] avatar Sep 13 '23 10:09 github-actions[bot]