KARAF / karaf star
2022-12-17
Open
#16 TOMCAT 에러 정보 숨기기 star
2022-12-17 Open
Tasks

web.xml 파일에 에러 페이지 설정#

<error-page>
    <error-code>404</error-code>
    <location>/error/404.jsp</location>
</error-page>
<error-page>
    <error-code>500</error-code>
    <location>/error/500.jsp</location>
</error-page>

Java Exception 객체에 따른 에러 설정#

<error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/error/exception.jsp</location>
</error-page>
<error-page>
    <exception-type>java.lang.NullPointerException</exception-type>
    <location>/servlet/ErrorServlet2</location>
</error-page>

Tomcat Server 정보 숨기기#

  • $CATALINA_HOME/lib 디렉토리
cd $CATALINA_HOME/lib
mkdir -p org/apache/catalina/util
cd org/apache/catalina/util
  • vim ServerInfo.properties
server.info=Linux

HTTP Header 에 서버 배너 삭제#

vim $CATALINA_BASE/conf/server.xml

    <Connector excecutor="tomcatThreadPool" port="8180" protocol="HTTP/1.1"
               connectionTimeout="20000" Server=" "
               redirectPort="81443" URIEncoding="UTF-8" />

자세한 오류 정보 숨기기#

  • vim $CATALINA_BASE/conf/server.xml
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
        <!-- ErrorReportValve //-->
        <Valve className="org.apache.catalina.valves.ErrorReportValve" showReport="false" showServerInfo="false" />
      </Host>
Issue Sharer
Comment 0

Add a comment
New subtask
Assignee
No assignee
Due date
No due date
Label
infra tomcat
Comment 0