如何禁用 websphere 8.5 中的目录浏览?
How to disable directory browsing in websphere 8.5?
我需要知道当用户在 webshere 8.5 上尝试访问资源文件夹而不是文件本身(例如,通过键入 http://domain/appname/resources/js
)时,如何禁用从浏览器检索 js/css 文件列表的功能.
根据 IBM 知识中心文档 Web Container directoryBrowsingEnabled
的默认值是 false
,这表明我没有必要定义:<enable-directory-browsing value="false"/>
on ibm-web-ext.xml
首先。
在我的案例中,WebSphere 生成 ibm-web-ext.xml
内容:
<?xml version="1.0" encoding="UTF-8"?>
<web-ext xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd" version="1.0">
<jsp-attribute name="reloadEnabled" value="true"/>
<jsp-attribute name="reloadInterval" value="5"/>
</web-ext>
如果我修改并替换 ibm-web-ext.xml
为内容:
<?xml version="1.0" encoding="UTF-8"?>
<web-ext xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd" version="1.0">
<jsp-attribute name="reloadEnabled" value="true"/>
<jsp-attribute name="reloadInterval" value="5"/>
<enable-directory-browsing value="false"/>
</web-ext>
应用程序重启后似乎没有任何变化。
为什么即使 directoryBrowsingEnabled
标志设置为 false
,也可以从浏览器访问 CSS / JS 资源文件列表?似乎仅 directoryBrowsingEnabled
是不够的。我错过了什么?
如果要在 Web 应用程序级别禁用静态文件浏览,请在 ibm-web-ext.xml 文件中也将 "fileServingEnabled" 属性 设置为 FALSE。
fileServingEnabled="false"
如果你想全局禁用它(应用服务器中的所有应用程序),那么使用com.ibm.ws.webcontainer.disallowAllFileServing
自定义属性
简短回答:WAS 的目录浏览已默认禁用。
请注意,当用户可以通过向上/向下单击文件夹来导航目录时,'directory browsing' 表示 FTP 风格的目录浏览。
当用户点击 http://domain/appname/resources/js
时,我的案例浏览器通过将文件夹下载为纯文本文件来响应 200 代码。所以之前没有提到'FTP'风格的浏览器案例。
除了其他静态资源配置外,还有 spring mvc 资源标签。
<mvc:resources mapping="/**" location="/resources/" />
我不认为标签本身是导致此问题的原因。但是,通过删除资源目录 URL 不再导致 200 状态代码。
通过移除的方式
应用程序也无法检索某些资源进行显示。
我需要知道当用户在 webshere 8.5 上尝试访问资源文件夹而不是文件本身(例如,通过键入 http://domain/appname/resources/js
)时,如何禁用从浏览器检索 js/css 文件列表的功能.
根据 IBM 知识中心文档 Web Container directoryBrowsingEnabled
的默认值是 false
,这表明我没有必要定义:<enable-directory-browsing value="false"/>
on ibm-web-ext.xml
首先。
在我的案例中,WebSphere 生成 ibm-web-ext.xml
内容:
<?xml version="1.0" encoding="UTF-8"?>
<web-ext xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd" version="1.0">
<jsp-attribute name="reloadEnabled" value="true"/>
<jsp-attribute name="reloadInterval" value="5"/>
</web-ext>
如果我修改并替换 ibm-web-ext.xml
为内容:
<?xml version="1.0" encoding="UTF-8"?>
<web-ext xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd" version="1.0">
<jsp-attribute name="reloadEnabled" value="true"/>
<jsp-attribute name="reloadInterval" value="5"/>
<enable-directory-browsing value="false"/>
</web-ext>
应用程序重启后似乎没有任何变化。
为什么即使 directoryBrowsingEnabled
标志设置为 false
,也可以从浏览器访问 CSS / JS 资源文件列表?似乎仅 directoryBrowsingEnabled
是不够的。我错过了什么?
如果要在 Web 应用程序级别禁用静态文件浏览,请在 ibm-web-ext.xml 文件中也将 "fileServingEnabled" 属性 设置为 FALSE。
fileServingEnabled="false"
如果你想全局禁用它(应用服务器中的所有应用程序),那么使用com.ibm.ws.webcontainer.disallowAllFileServing
自定义属性
简短回答:WAS 的目录浏览已默认禁用。
请注意,当用户可以通过向上/向下单击文件夹来导航目录时,'directory browsing' 表示 FTP 风格的目录浏览。
当用户点击 http://domain/appname/resources/js
时,我的案例浏览器通过将文件夹下载为纯文本文件来响应 200 代码。所以之前没有提到'FTP'风格的浏览器案例。
除了其他静态资源配置外,还有 spring mvc 资源标签。
<mvc:resources mapping="/**" location="/resources/" />
我不认为标签本身是导致此问题的原因。但是,通过删除资源目录 URL 不再导致 200 状态代码。
通过移除的方式
应用程序也无法检索某些资源进行显示。