Apache httpd:如何在重定向请求上设置头值



我使用的是apache httpd 2.4.34,下面是httpd.conf配置。

Header always unset X-Powered-By
Header unset X-Powered-By
## Header to set Server
Header always set Server "Server"
RewriteEngine On
RewriteRule  ^/$ /login.do [R,L]
ProxyPass / ajp://x.x.x.x:8109/ connectiontimeout=300 timeout=300
ProxyPassReverse / ajp://x.x.x.x:8109/

在这里,我将从响应标头中删除服务器令牌的详细信息,并将值设置为server。根据root请求,如果我将点击https://example.com/则服务器将把请求重定向到https://example.com/login.do使用"重写规则"。

在上面提供的场景中,原始服务器详细信息如下所示被接收回来。

Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.1e-fips mod_auth_kerb/5.4

对于所有其他请求,它返回的值低于预期值

Server: Server

如何使用RewriteRule删除或设置重定向请求的响应标头值?

所以我认为您正在寻找的是

参考编号:http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-For}i !^xxx.xxx.xxx.xxx 
RewriteRule  "^/$"                 "/do.html"     [L]
ServerSignature Off
ProxyPass / ajp://x.x.x.x:8109/ connectiontimeout=300 timeout=300
ProxyPassReverse / ajp://x.x.x.x:8109/

跳过服务器签名不太安全,但听起来像是在深入处理安全问题。我希望这能有所帮助。

  • 享受

使用ProxyAddHeaders指令https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxyaddheaders

最新更新