### 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
Verified with EAP 6.4.11.CP.CR1;
Retroactively bulk-closing issues from released EAP 6.4 cummulative patches.