zoukankan      html  css  js  c++  java
  • tomcat的安全配置(禁用http方法,部署多个应用,启用从安全cookie,指定错误页面和显示信息)

    配置版本:tomcat6

    1,虚拟路径,可以配置多个host在一个tomcat中,docbase是web应用目录,此处在server.xml中添加应用配置,要让server.xml配置生效需要重启tomcat


    <Host name="XXXXx" appBase="D:webroot"
    unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">

    <Context path="/" reloadable="true" docBase="D:webrootxxxWebRoot" />

    </Host>

    2,禁用不需要的http方法,一般禁用delete,put,默认情况tomcat禁止了delete,put,访问返回403-forbiden,此处在web.xml的<web-app>中添加如下禁用配置,

    要让web.xml配置生效需要重启tomcat


    <security-constraint>
    <web-resource-collection>
    <url-pattern>/*</url-pattern>
    <http-method>PUT</http-method>
    <http-method>DELETE</http-method>
    <http-method>HEAD</http-method>
    <http-method>OPTIONS</http-method>
    <http-method>TRACE</http-method>
    </web-resource-collection>
    <auth-constraint>
    </auth-constraint>
    </security-constraint>
    <login-config>
    <auth-method>BASIC</auth-method>
    </login-config>

    3,启用安全cookie,防止xss跨站点攻击,tomcat6开始支持此属性,此处在context.xml中添加启用配置,context.xml配置即调用时生效不需要重启tomcat

    http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

    <Context useHttpOnly="true">

    4,修改tomcat版本信息,防泄漏:

    1)进入apache-tomcat目录lib下,找到catalina.jar,使用压缩工具依次找到orgapachecatalinautil下的ServerInfo.properties

    打开ServerInfo.properties编辑:(去掉版本信息)如下

    server.info=Apache Tomcat

    server.number=

    server.built=

    2)设置web.xml的error-page,指定返回页面。此处可在应用中配置,应用中配置则只在当前应用生效。

       <error-page>

           <error-code>500</error-code>

           <location>/500.html</location>

       </error-page>

  • 相关阅读:
    Azure HPC Pack Cluster添加辅助节点
    Azure HPC Pack 辅助节点模板配置
    Azure HPC Pack配置管理系列(PART6)
    Windows HPC Pack 2012 R2配置
    Azure HPC Pack 节点提升成域控制器
    Azure HPC Pack VM 节点创建和配置
    Azure HPC Pack 部署必要条件准备
    Azure HPC Pack 基础拓扑概述
    Azure VM 性能计数器配置
    Maven私仓配置
  • 原文地址:https://www.cnblogs.com/codeinet/p/5844651.html
Copyright © 2011-2022 走看看