웹개발/WAS

[Tomcat]http로 접속시 https로 리디렉션 설정

토킹포테토 2023. 3. 24. 14:50
728x90

가끔 도메인만 입력할 경우 Bad Request 오류가 발생한다.

 

아래와 같이 파일을 수정하면 문제를 해결 할 수 있다.

 

1. tomcat - server.xml 수정

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<server>
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

... 중간 생략...

<Connector port="80" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="443" />

<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol"
           maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS"
           keystoreFile="{keystoreFile}" keystorePass="{keystorePass}" />

<Connector port="8009" protocol="AJP/1.3" redirectPort="443" />

... 중간 생략...

</server>

 

2. tomcat - web.xml 수정

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  version="3.1">

    ... 중간 생략...

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>HTTP</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

</web>

'웹개발 > WAS' 카테고리의 다른 글

[TOMCAT] CMD 창 에러나도 안 닫히게 하기  (0) 2023.05.26
[nginx] mac에서 nginx 설치하기  (0) 2022.11.27