为什么 SERVER_NAME 变量在 tomcat 8 URL 重写中返回不正确的值?
Why is SERVER_NAME variable returning incorrect value in tomcat 8 URL Rewrite?
我正在将 URL 重写功能从 apache mod_rewrite 迁移到 Tomcat 8 的 RewriteValve。我在负载平衡器后面有 apache Web 服务器 运行。有一些 URL 正在根据域名重写。
RewriteCond %{SERVER_NAME} ^xyz.com
RewriteRule /pattern$ /substitution [L]
在 Apache 的 mod_rewrite 中,SERVER_NAME 变量工作正常。但是在 tomcat 8 中,变量返回机器的 IP 地址而不是服务器名称。
中的变量部分下
SERVER_NAME The server's hostname or IP address.
HTTP_HOST The web site that the client requested.
在 RewriteRules 中使用 HTTP_HOST 变量解决了我的问题。
我正在将 URL 重写功能从 apache mod_rewrite 迁移到 Tomcat 8 的 RewriteValve。我在负载平衡器后面有 apache Web 服务器 运行。有一些 URL 正在根据域名重写。
RewriteCond %{SERVER_NAME} ^xyz.com
RewriteRule /pattern$ /substitution [L]
在 Apache 的 mod_rewrite 中,SERVER_NAME 变量工作正常。但是在 tomcat 8 中,变量返回机器的 IP 地址而不是服务器名称。
SERVER_NAME The server's hostname or IP address.
HTTP_HOST The web site that the client requested.
在 RewriteRules 中使用 HTTP_HOST 变量解决了我的问题。