HƯỚNG DẪN THIẾT LẬP CHÍNH SÁCH BẢO MẬT WEB SERVER TOMCAT 7

HƯỚNG DẪN THIẾT LẬP CHÍNH SÁCH BẢO MẬT​​ WEB SERVER​​ TOMCAT​​ 7​​ 

  • Gỡ/tắt bỏ các thành phần mặc định khi cài đặt Web Server

  • Gỡ bỏ các thư mục/trang mặc định.

  • Xóa file, thư mục tại đường dẫn CATALINA_HOME/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav,​​ manager, docs,​​ examples)

  • Xóa file CATALINA_HOME/conf/Catalina/localhost/host-manager.xml và ​​ CATALINA_HOME/conf/Catalina/localhost/manager.xml.

  • Tắt các Module/Extension không sử dụng

  • Trên file server.xml tại đường dẫn CATALINA_HOME/conf/server.xml, tìm dòng ​​ <connector … protocol=”AJP/…”> ​​ và chuyển sang dạng ghi chú.

  • Restart lại Tomcat.

  • Thay đổi các thành phần mặc định.

  • Thay đổi thông báo lỗi mặc định của Web Server.

  • Tạo các error.html ở thư mục gốc của ứng dụng với nội dung phù hợp với từng ứng dụng.

  • Mở​​ file web.xml​​ tại đường dẫn CATALINA_HOME/conf/web.xml,​​ thay đổi thông báo lỗi với các mã lỗi 400, 401, 402, 403, 404, 500, 501, 502, 503, ​​ bằng cách thêm các nội dung sau vào trước thẻ đóng </web-app>

<error-page>

<error-code>400</error-code>

<location>/error.html</location>

</error-page>

<error-page>

<error-code>401</error-code>

<location>/error.html</location>

</error-page>

<error-page>

<error-code>402</error-code>

<location>/error.html</location>

</error-page>

<error-page>

<error-code>403</error-code>

<location>/error.html</location>

</error-page>

<error-page>

<error-code>404</error-code>

<location>/error.html</location>

</error-page>

<error-page>

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

<location>/error.html</location>

</error-page>

<error-page>

<error-code>501</error-code>

<location>/error.html</location>

</error-page>

<error-page>

<error-code>502</error-code>

<location>/error.html</location>

</error-page>

<error-page>

<error-code>403</error-code>

<location>/error.html</location>

</error-page>

  • Restart lại Tomcat.

  • Chỉ cho phép thực thi các phương thức GET, POST, HEAD.

  • Mở file web.xml​​ tại đường dẫn CATALINA_HOME/conf/web.xml​​ thêm các dòng sau ở cuối file trước thẻ đóng </web-app>

<security-constraint>

<web-resource-collection>

<web-resource-name>restricted methods</web-resource-name>

<url-pattern>/*</url-pattern>

<http-method>PUT</http-method>

<http-method>DELETE</http-method>

<http-method>OPTIONS</http-method>

<http-method>TRACE</http-method>

</web-resource-collection>

<auth-constraint />

</security-constraint>

  • Restart lại Tomcat.

  • Cấu hình giới hạn truy cập.

  • Giới hạn địa chỉ IP truy cập vào trang, chức năng quản trị.

  • Mở file​​ server.xml tại đường dẫn CATALINA_HOME/conf/server.xml

  • Chỉ cho phép truy cập cổng SHUTDOWN từ địa chỉ loopback​​ :​​ Thêm ​​ thuộc tính address="127.0.0.1" trong thông số về cổng SHUTDOWN.

<Server address="127.0.0.1" port="8005" shutdown="SHUTDOWN">

  • Restart lại Tomcat.

  • Không cho phép liệt kê file, thư mục.​​ 

  • Mở file​​ web.xml tại đường dẫn CATALINA_HOME/conf/web.xml tìm section <init-param> trong section <servlet>​​ với ”​​ <servlet-name>default</servlet-name>”​​ thay đổi thuộc tính listings là false​​ 

<init-param>

<param-name>listings</param-name>

<param-value>false</param-value>

</init-param>

  • Restart lại Tomcat.

BÀI VIẾT CÙNG CHUYÊN MỤC