我通过更改以下配置在 Wildfly 9.0 中阻止了 http 协议(protocol)(仅启用 https)
Changed connector-ref="default" to connector-ref="default-ssl"
<subsystem xmlns="urn:jboss:domain:remoting:3.0">
<endpoint worker="default"/>
<http-connector name="http-remoting-connector" connector-ref="default-ssl" security-realm="ApplicationRealm"/>
</subsystem>
Commented the http-listener
<subsystem xmlns="urn:jboss:domain:undertow:2.0">
<buffer-cache name="default"/>
<server name="default-server">
<!-- <http-listener name="default" socket-binding="http" redirect-socket="https"/> -->
<https-listener name="def.....
它起作用了..我能够阻止 http 并仅启用 https 协议(protocol) 访问。理想情况下它应该拒绝 http 请求。但是,现在的问题是,每当我访问http://localhost:8080/MyWebApp/时,它拒绝http请求,但同时网页正在下载一个空白的下载文件。为什么 ???
谢谢。
最佳答案
您应该将 http 请求重定向到 https,而不是禁用 http:
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" redirect-port="443" />
在处理程序部分添加一个重定向处理程序,过程如下:
<host name="other-host" alias="www.mysite.com, ${prop.value:default-alias}" default-web-module="something.war" disable-console-redirect="true">
<location name="/" handler="welcome-content">
<filter-ref name="redirects" predicate="!secure" />
</location>
<filter-ref name="headers"/>
</host>
</server>
... https://myserver/'"重定向 = "true"/>
关于java - 在 Wildfly9 中访问 http 时,正在下载一个空白的下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37829521/