Getting IllegalArgumentException when using colon to specify port number with server vairable in rewrite rule in JBoss EAP 6.x
Issue
To force redirect to https, I configured 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>
then got the following IllegalArgumentException:
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
Same issue occurred when using the followingrewrite.properties with setting rewrite valve in WEB-INF/jboss-web.xml:
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}:8443%{REQUEST_URI} [R,L]
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 6.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.