This is my first contact with Wildfly/JBoss and JAVA web technology. I want to write this upfront to avoid confusion and to indicate I'm a newbie :)
I'm trying to setup rewrite rules for a website that is hosted on WildFly 16 server. I have a Linux machine that has Apache installed and configured as a reverse-proxy. On the same machine is a docker that runs Wildfly. I have access to WAR file and I try to do all the modifications there (I don't have access to project files)
Part of the website is build using react and it needs those 3 rewrites:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html [L]
I've checked those rules on Apache with PHP (in htaccess file) and they work perfectly.
My problem is I can't get RewriteRules to work on Wildfly.
According to the docs (https://docs.jboss.org/jbossweb/7.0.x/rewrite.html) I need to add:
<valve>
<class-name>"org.jboss.web.rewrite.RewriteValve"</class-name>
</valve>
to jboss-web.xml
. I did that, but in WAR wile, so now the WEB-INF\jboss-web.xml
file has this content:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web version="8.0" xmlns="http://www.jboss.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/schema/jbossas/jboss-web_8_0.xsd">
<valve>
<class-name>"org.jboss.web.rewrite.RewriteValve"</class-name>
</valve>
<context-root>/TestYourSkills</context-root>
</jboss-web>
then (also according to the docs) I've added rewrite.properties
file in WEB-INF folder with the following content:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/$ /index.html [L]
but I can't get that to work. I've tried adding even simpler rules, but all my attempts failed.
Am I doing something wrong?
Maybe I need to enable something else or add additional JAR files to WEB-INF\lib
?
I'm totally new to WildFly, but I spend almost two days trying different things and searching over the net.
Any advice is more than welcome.