반응형
[Tomcat9] http -> https로 리다이렉트 설정하기 (SSL설정)
server.xml에 SSL설정
$ tomcat/conf/server.xml
주석처리 되어있는 부분을 풀어 주시고
파일에 https 설정을 443 포트로 설정하고, http 설정을 80 포트로 설정해주세요.
그리고, 키 파일과 패스워드를 입력해주세요 !
<?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>
톰캣설정이 끝났으면 자바 프로젝트에 web.xml 변경하러 !
web.xml에 리다이렉트 설정 추가한다.
web.xml 에 <security-constraint> 설정을 추가 후
Tomcat 을 재시작하면,
http로 접근을 했을때 https로 리다이렉트 잘 될꺼에요 !
<?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>
728x90
반응형
'여러가지 > 기타' 카테고리의 다른 글
[Armoury Crate] 노트북(ASUS ROG) 부팅 시 '챙~', 칼 소리 안 나오게 하는 방법 !! (0) | 2022.08.08 |
---|---|
[구글 스프레드시트] Google Sheets 스크립트 이용하여 맨 아래로 이동 (트리거를 이용하여 자동실행) (0) | 2022.07.19 |
[Putty] 푸티 자동 종료, 세션 끊김 방지 설정하기 (지속적으로 패킷보내기) (0) | 2022.05.19 |
[노트북] 닫아도 전원 꺼지지 않게 설정하는 방법 !! (0) | 2022.05.04 |
[Jetbrains] 파이참(Pycharm) IDE 실행시 프로젝트 선택창(welcome screen)으로 열기 (0) | 2022.04.27 |
댓글