Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server name blank after upgrading to Http2 on Tomcat 9 #264

Open
catsncode opened this issue Mar 5, 2024 · 0 comments
Open

Server name blank after upgrading to Http2 on Tomcat 9 #264

catsncode opened this issue Mar 5, 2024 · 0 comments

Comments

@catsncode
Copy link

catsncode commented Mar 5, 2024

I've been using this initial rule for a long time and it's worked great. I am attempting to upgrade my Tomcat to use http/2. When I do so, it causes the hostname used to match to be blank, as shown below. Any ideas on how to fix this? I am using 4.0.3 as I see that is the preferred version for Tomcat 9. Thanks so much for any help!

Update: I was able to move this logic to a Tomcat filter, so I don't really need a fix (and I can't run new versions anyway), but FYI in case you want to look at it or someone else runs into it.

<urlrewrite use-query-string="true">          
<rule>
   <name>redirect</name>
   <condition name="host" operator="notequal">^www\.myhost\.com</condition>
   <condition name="host" operator="notequal">^localhost</condition>
   <from>^/(.*)</from>
   <to type="permanent-redirect" last="true">https://www.myhost.com/$1</to>
</rule>

when going to localhost in my browser, I get incorrectly redirected as localhost is not supposed to redirect. Here is the debug log. Note that it correctly shows localhost on the first line, but then attempts to match the rules against "".

org.tuckey.web.filters.urlrewrite.utils.ServerNameMatcher DEBUG: looking for hostname match on current server name localhost
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: checking for status path on /
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: processing request for /
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: redirect (rule 0) run called with /
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: matched "from"
org.tuckey.web.filters.urlrewrite.Condition DEBUG: evaluating "" against ^www.myhost.com
org.tuckey.web.filters.urlrewrite.Condition DEBUG: not equal operator in use
org.tuckey.web.filters.urlrewrite.Condition DEBUG: evaluating "" against ^localhost
org.tuckey.web.filters.urlrewrite.Condition DEBUG: not equal operator in use
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: conditions match
org.tuckey.web.filters.urlrewrite.substitution.MatcherReplacer DEBUG: found 1
org.tuckey.web.filters.urlrewrite.substitution.MatcherReplacer DEBUG: replaced sb is https://www.myhost.com/
org.tuckey.web.filters.urlrewrite.RuleExecutionOutput DEBUG: needs to be permanentely redirected to https://www.myhost.com/
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: rule is last

If I change the tomcat config back to not use http/2, it works as usual:

org.tuckey.web.filters.urlrewrite.utils.ServerNameMatcher DEBUG: looking for hostname match on current server name localhost
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: checking for status path on /
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: processing request for /
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: redirect (rule 0) run called with /
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: matched "from"
org.tuckey.web.filters.urlrewrite.Condition DEBUG: evaluating "localhost" against ^www.myhost.com
org.tuckey.web.filters.urlrewrite.Condition DEBUG: not equal operator in use
org.tuckey.web.filters.urlrewrite.Condition DEBUG: evaluating "localhost" against ^localhost
org.tuckey.web.filters.urlrewrite.Condition DEBUG: not equal operator in use
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: conditions do not match
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Rule 1 run called with /
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Rule 2 run called with /
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: matched "from"
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: 'to' is '-', no substitution, passing through URL
org.tuckey.web.filters.urlrewrite.RuleExecutionOutput DEBUG: needs no substitution
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: rule is last

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant