带有 mod_rewrite 的 Apache 转发代理

带有 mod_rewrite 的 Apache 转发代理

故事: 我必须将请求(带证书检查)转发到 URL 长度超过 96 个字符的站点。Apache mod_proxy 实现无法处理超过 96 个字符的 URL。我尝试使用带 [P] 标志的 mod_rewrite 的 RewriteRule,但它仍然向客户端响应 HTTP 301,而不是代理请求。当我通过短于 96 个字符的 mod_proxy (ProxyPass) 进行测试时,它运行良好。

ProxyPass 示例: ProxyPass /LOCATION“https://we_need_to_reach_this_site”

RewriteRule 示例: 重写规则 "^/LOCATION(.*)$" "https://we_need_to_reach_this_site" [P]

问题 1: 我可以使用 mod_rewrite 来代理请求,就像使用 mod_proxy 使用 96+ 个字符的 URL 一样吗?

问题2: 当通过 mod_rewrite 进行代理时,我可以发送证书来验证我自己,就像通过 mod_proxy (SSLProxyMachineCertificateFile) 一样吗?

挑战: 它位于 Oracle Linux、Apache 版本 2.4.6 上,不幸的是它无法更改。

提前谢谢你

Update1:​​工作错误时的日志:

[Wed Jun 03 13:52:05.978513 2020] [core:trace3] [pid 12411] request.c(368): [client host:port] fixups hook gave 301: /LOCATION
[Wed Jun 03 13:52:05.978556 2020] [http:trace3] [pid 12411] http_filters.c(1129): [client host:port] Response sent with status 301, headers:
[Wed Jun 03 13:52:05.978558 2020] [http:trace5] [pid 12411] http_filters.c(1136): [client host:port]   Date: Wed, 03 Jun 2020 11:52:05 GMT
[Wed Jun 03 13:52:05.978559 2020] [http:trace5] [pid 12411] http_filters.c(1139): [client host:port]   Server: Apache/2.4.6 ()
[Wed Jun 03 13:52:05.978565 2020] [http:trace4] [pid 12411] http_filters.c(958): [client host:port]   Strict-Transport-Security: max-age=31536000
[Wed Jun 03 13:52:05.978567 2020] [http:trace4] [pid 12411] http_filters.c(958): [client host:port]   Location: https://host:port/LOCATION/
[Wed Jun 03 13:52:05.978568 2020] [http:trace4] [pid 12411] http_filters.c(958): [client host:port]   Content-Length: 243
[Wed Jun 03 13:52:05.978569 2020] [http:trace4] [pid 12411] http_filters.c(958): [client host:port]   Keep-Alive: timeout=15, max=100
[Wed Jun 03 13:52:05.978571 2020] [http:trace4] [pid 12411] http_filters.c(958): [client host:port]   Connection: Keep-Alive
[Wed Jun 03 13:52:05.978572 2020] [http:trace4] [pid 12411] http_filters.c(958): [client host:port]   Content-Type: text/html; charset=iso-8859-1

相关内容