Site icon Knowledge Base| Kiến thức Dịch vụ P.A Việt Nam

Hướng dẫn cấu hình chuyển hướng http sang https trên Tomcat

Bước 1: Bạn mở file cấu hình web.xml của tomcat. Thường nằm trong đường dẫn thư mục: tomcat/config/. Sau đó thêm đọan code sau vào thẻ  <web-app>:

<web-app>
...
<security-constraint>
    <web-resource-collection>
        <web-resource-name>Protected Context</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <!-- auth-constraint goes here if you require authentication -->
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>
</web-app>

Bước 2:Tiếp theo bạn mở file server.xml và chèn đoạn code sau vào thẻ <Host>:

<Valve className="org.apache.catalina.valves.RemoteIpValve"
remoteIpHeader="x-forwarded-for"
protocolHeader="x-forwarded-proto"
protocolHeaderHttpsValue="https" />

Cuối cùng: Bạn cho restart lại service tomcat.

Rate this post
Exit mobile version