简体   繁体   中英

Set proxypass domain from header

Trying to find a way to implement a proxypass based on the incoming header.

For instance:

proxyPass / https://%{{x-backend-host}}/

Where X-backend-host will be in the request headers.

The idea behind this is to have multiple incoming domains, ie one.example.com, two.example.com, three.example.com and have them point at there own unique backends.

Does anyone have any ideas or references I can look at to implement a scenario like this.

you need to do this via a rewrite rule of mod_rewrite. From the docs of ProxyPass:

 If you require a more flexible reverse-proxy configuration, see the RewriteRule directive with the [P] flag.

Read hear about RewriteRule: https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewriterule (scroll down where the differen flags are described and look for the [P] flag)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM