JBoss/Wildfly => standalone.xml
Redirect http to https only if the request url contains a domain name. If the web site access from ip address do not redirect.
http://x.x.x.x:8080 -> do not redirect
http://xx.example.com -> redirect to https://xx.example.com
I am using http to https redirect using the below code in standalone.xml
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
<https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
<host name="default-host" alias="localhost">
<filter-ref name="http-to-https" predicate="equals(%p,8080)"/>
</host>
</server>
<filters>
<rewrite name="http-to-https" target="https://%v%U%q" redirect="true"/>
</filters>
But in this case redirect all request from ip or domain name if port is 8080.
http://x.x.x.x:8080 -> redirecting to https://x.x.x.x:8080
http://xx.example.com -> redirecting to https://xx.example.com
But i do not redirect if request from ip, only redirect from domain name.
I am using http to https redirect using the below code in standalone.xml. But its not redirect in both conditions.
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
<https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
<host name="default-host" alias="localhost">
<filter-ref name="http-to-https" predicate="regex(pattern='/http://(.*).example.com/g') and equals(%p,8080)"/>
</host>
</server>
<filters>
<rewrite name="http-to-https" target="https://%v%U%q" redirect="true"/>
</filters>
Thanks
Aucun commentaire:
Enregistrer un commentaire