【问题标题】:Set proxypass domain from header从标头设置 proxypass 域
【发布时间】:2019-01-28 14:11:34
【问题描述】:

试图找到一种基于传入标头实现代理传递的方法。

例如:

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

X-backend-host 将在请求标头中的位置。

这背后的想法是拥有多个传入域,即 one.example.com、two.example.com、three.example.com,并让它们指向各自独特的后端。

有没有人有任何想法或参考资料可供我参考以实现这样的场景。

【问题讨论】:

  • 有人有什么想法吗?

标签: apache nginx mod-proxy proxypass hostheaders


【解决方案1】:

您需要通过 mod_rewrite 的重写规则来执行此操作。来自ProxyPass的docs

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

阅读了解 RewriteRule: https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewriterule (向下滚动描述不同标志的位置并查找 [P] 标志)

【讨论】:

    猜你喜欢
    • 2018-05-13
    • 2013-03-13
    • 1970-01-01
    • 2010-11-07
    • 2014-11-22
    • 2017-11-18
    • 1970-01-01
    • 1970-01-01
    • 2011-09-27
    相关资源
    最近更新 更多