- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在从 JBoss 6.4.3 迁移到 JBoss 7.2,在部署期间看到了 Valves are no longer supported
警告。这来自一个 jboss-web.xml
文件:
<valve>
<class-name>org.jboss.web.rewrite.RewriteValve</class-name>
</valve>
...和相应的rewrite.properties
文件:
RewriteCond %{HTTP:X-Forwarded-Proto} http
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
谁能建议如何为 Undertow 重写这个(没有双关语)?
最佳答案
您可以创建一个 rewrite
filter在 Undertow 子系统中,然后在配置文件(standalone.xml 或 domain.xml - 取决于您启动应用程序的模式)中的服务器主机中引用它服务器)。
我可以想到两个可能对您有帮助的选项:
使用JBoss 应用服务器客户端
(应该放在path/to/jboss-7.2/bin/
)
redirect-http-to-https
创建重写过滤器:./jboss-cli.sh --connect --command="/subsystem=undertow/configuration=filter/rewrite=redirect-http-to-https:add(redirect=\"true\",target=\"https://%{LOCAL_SERVER_NAME}%{REQUEST_URL}\")"
redirect-http-to-https
:./jboss-cli.sh --connect --command="/subsystem=undertow/server=default-server/host=default-host/filter-ref=redirect-http-to-https:add(predicate=\"equals(%p,80)\")"
手动编辑相应的配置文件(例如 standalone.xml
)
<subsystem xmlns="urn:jboss:domain:undertow:11.0" default-server="default-server" [...]>
<buffer-cache name="default"/>
<server name="default-server">
[...]
<host name="default-host" alias="localhost">
<filter-ref name="redirect-http-to-https" predicate="equals(%p,80)"/>
</host>
</server>
[...]
<filters>
<rewrite name="redirect-http-to-https" target="https://%{LOCAL_SERVER_NAME}%{REQUEST_URL}" redirect="true"/>
</filters>
</subsystem>
注意:对于 Undertow 交换属性(例如 LOCAL_SERVER_NAME
),请参阅 Undertow documentation .此外,filter-ref
中的 predicate=\"equals(%p,80)\"
部分检查请求的端口(%p
-> 只是另一个 Undertow 交换属性),如果它等于 80
,那么它会触发我们的重定向过滤器 redirect-http-to-https
- 你可以更改端口 80
根据您的需要。
关于java - 如何为 Undertow/JBoss 7.2 EAP 重写 RewriteValve?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62898780/
是否可以使用 RewriteValve 以某种方式自定义嵌入式 tomcat ?正如我在 api 中看到的那样目前只有 addContextValves 的方法和 addEngineValves但正如
我正在 tomcat 中运行一个应用程序,我不允许更改其配置。因此,例如我的数据库连接配置在 tomcat/conf/Catalina/localhost/context.xml.default 现在
我正在从 JBoss 6.4.3 迁移到 JBoss 7.2,在部署期间看到了 Valves are no longer supported 警告。这来自一个 jboss-web.xml 文件:
前提 在安装了最新 Apache2 的 Ubuntu 16.04 服务器上,我有不同的虚拟主机, 每个都正确配置(并使用 Let's Encrypt 保护): /etc/apache2/sites-e
我是一名优秀的程序员,十分优秀!