Bug 1341410 - [GSS](6.4.z) Getting IllegalArgumentException when using colon to specify port number with server vairable in rewrite rule
Summary: [GSS](6.4.z) Getting IllegalArgumentException when using colon to specify por...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Web
Version: 6.4.8
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: CR1
: EAP 6.4.11
Assignee: jboss-set
QA Contact: Radim Hatlapatka
URL:
Whiteboard:
Depends On:
Blocks: 1316573 eap6411-payload
TreeView+ depends on / blocked
 
Reported: 2016-06-01 03:00 UTC by Masafumi Miura
Modified: 2019-11-14 08:14 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-01-17 13:11:44 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 2348151 0 None None None 2016-06-01 03:11:44 UTC

Description Masafumi Miura 2016-06-01 03:00:11 UTC
### Description of problem:

Getting IllegalArgumentException when using colon to specify port number with server vairable in rewrite rule


### How reproducible:

Anytime


### Steps to Reproduce:

1. Set the following global rewrite rule in web subsystem in standalone.xml

        <subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
            ...
            <virtual-server name="default-host" enable-welcome-root="true">
                ...
                <rewrite pattern="^/(.*)$" substitution="https://%{HTTP_HOST}:8443%{REQUEST_URI}" flags="RL">
                    <condition test="%{HTTPS}" pattern="off" />
                </rewrite>
            </virtual-server>
        </subsystem>

   or use the following rewrite.properties with setting rewrite valve in jboss-web.xml 

       RewriteCond %{HTTPS} !=on
       RewriteRule .* https://%{HTTP_HOST}:8443%{REQUEST_URI} [R,L]

2. Start JBoss EAP 


### Actual results:

~~~
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-37) MSC000001: Failed to start service jboss.web.host.default-host: org.jboss.msc.service.StartException in service jboss.web.host.default-host: java.lang.IllegalArgumentException: https://%{HTTP_HOST}:8443%{REQUEST_URI}
	at org.jboss.as.web.WebVirtualHostService.createRewriteValve(WebVirtualHostService.java:225)
	at org.jboss.as.web.WebVirtualHostService.start(WebVirtualHostService.java:88)
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1980) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1913) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_77]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_77]
	at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_77]
Caused by: java.lang.IllegalArgumentException: https://%{HTTP_HOST}:8443%{REQUEST_URI}
	at org.jboss.web.rewrite.Substitution.parse(Substitution.java:195)
	at org.jboss.web.rewrite.RewriteRule.parse(RewriteRule.java:45)
	at org.jboss.web.rewrite.RewriteValve.parse(RewriteValve.java:251)
	at org.jboss.web.rewrite.RewriteValve.setConfiguration(RewriteValve.java:184)
	at org.jboss.as.web.WebVirtualHostService.createRewriteValve(WebVirtualHostService.java:223)
	... 6 more
~~~

### Expected results:

No exception.


### Workaround

If a fixed hostname is acceptable instead of using server variable %{HTTP_HOST}, you can workaround by changing your rewrite rule from:

    <rewrite pattern="^/(.*)$" substitution="https://%{HTTP_HOST}:8443%{REQUEST_URI}" flags="RL">
        <condition test="%{HTTPS}" pattern="off" />
    </rewrite>


to:

    <rewrite pattern="^/(.*)$" substitution="https://www.example.com:8443%{REQUEST_URI}" flags="RL">
        <condition test="%{HTTPS}" pattern="off" />
    </rewrite>


### Additional info:

Similar issue has already been fixed in tomcat trunk by https://svn.apache.org/viewvc?view=revision&revision=1730612

Comment 9 Ivo Hradek 2016-10-04 06:49:44 UTC
Verified with EAP 6.4.11.CP.CR1;

Comment 10 Petr Penicka 2017-01-17 13:11:44 UTC
Retroactively bulk-closing issues from released EAP 6.4 cummulative patches.


Note You need to log in before you can comment on or make changes to this bug.