Migration from Jboss7 to Wildfly: allow access to servlet only from specific IPs

本秂侑毒 提交于 2019-12-11 18:40:24

问题


I'm migrating an application from JBoss7 to Wildfly.

On JBoss I was allowing the access to one of the servlet from specific IPs using the valve element in jboss-web.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
  <context-root>/test-war</context-root>
  <valve>
    <class-name>org.apache.catalina.valves.RemoteAddrValve</class-name>
    <param>
      <param-name>allow</param-name>
      <param-value>127\..*\..*\..*,0:0:0:0:0:0:0:1%0</param-value>
    </param>
  </valve>
</jboss-web>

I would like to reproduce this functionality in wildfly but I cannot find an equivalent function.


回答1:


Undertow, a new webserver in WildFly, doesn't support Valves (which come from Tomcat).

If you don't need to do filtering on a server level (i.e. if the deployment level is sufficient), then you can simply implement servlet Filter with the same functionality. This is portable solution covered by Servlet specification.

Look at simple filter example with hardcoded IP range.



来源:https://stackoverflow.com/questions/23921533/migration-from-jboss7-to-wildfly-allow-access-to-servlet-only-from-specific-ips

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!