스프링 부트 개념과 활용
3. 스프링 부트 원리
포스팅 참조 정보
GitHub
공부한 내용은 GitHub에 공부용 Organizations에 정리 하고 있습니다
해당 포스팅에 대한 내용의 GitHub 주소
실습 내용이나 자세한 소스코드는 GitHub에 있습니다
포스팅 내용은 간략하게 추린 핵심 내용만 포스팅되어 있습니다
https://github.com/freespringlecture/springboot-concept-uses/tree/chap03-07-https_http2
freespringlecture/springboot-concept-uses
백기선님의 스프링 부트 개념과 활용 강의 내용 정리. Contribute to freespringlecture/springboot-concept-uses development by creating an account on GitHub.
github.com
해당 포스팅 참고 인프런 강의
https://www.inflearn.com/course/%EC%8A%A4%ED%94%84%EB%A7%81%EB%B6%80%ED%8A%B8/dashboard
스프링 부트 개념과 활용 - 인프런
스프링 부트의 원리 및 여러 기능을 코딩을 통해 쉽게 이해하고 보다 적극적으로 사용할 수 있는 방법을 학습합니다. 중급 프레임워크 및 라이브러리 Spring Spring Boot 온라인 강의
www.inflearn.com
실습 환경
- Java Version: Java 11
- SpringBoot Version: 2.1.2.RELEASE
7. 내장 웹 서버 응용 2부: HTTPS와 HTTP2
https://opentutorials.org/course/228/4894
HTTPS와 SSL 인증서 - 생활코딩
HTTPS VS HTTP HTTP는 Hypertext Transfer Protocol의 약자다. 즉 Hypertext 인 HTML을 전송하기 위한 통신규약을 의미한다. HTTPS에서 마지막의 S는 Over Secure Socket Layer의 약자로 Secure라는 말을 통해서 알 수 있듯이 보안이 강화된 HTTP라는 것을 짐작할 수 있다. HTTP는 암호화되지 않은 방법으로 데이터를 전송하기 때문에 서버와 클라이언트가 주고 받는 메시지를 감청하는 것이
opentutorials.org
https://gist.github.com/keesun/f93f0b83d7232137283450e08a53c4fd
Spring Boot SSL Sample (self signed)
Spring Boot SSL Sample (self signed). GitHub Gist: instantly share code, notes, and snippets.
gist.github.com
HTTPS 설정하기
- 키스토어 만들기
- HTTP는 못쓰네?
HTTP 커넥터는 코딩으로 설정하기
HTTP2 설정
server.http2.enable
- 사용하는 서블릿 컨테이너 마다 다름
keystore 인증서 생성
터미널에서 아래의 명령어로 keystore 파일 생성
keytool -genkey
-alias tomcat
-storetype PKCS12
-keyalg RSA
-keysize 2048
-keystore keystore.p12
-validity 4000
인증서 alias를 tomcat이라고 주고 server.ssl.keyAlias=tomcat
이라고 주지 않으면 아래와 같은 에러가 발생
curl: (35) error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
application.properties
에 생성된 keystore 인증서 설정
classpath에 keystore.p12 파일이 있으면 server.ssl.key-store=classpath:keystore.p12
server.ssl.key-store=keystore.p12
server.ssl.key-store-password=123456
server.ssl.keyStoreType=PKCS12
server.ssl.keyAlias=spring
위 와 같이 설정하면 자동으로 HTTPS 가 설정되는데 공식인증기관에서 발급된 인증서가 아니라 안전하지 않다고 경고함
HTTP 커넥터가 하나인데 거기에 HTTPS를 설정해서 더이상 HTTP는 사용할 수 없음
curl http2 지원되도록 설치
# install cURL with nghttp2 support
brew install curl --with-nghttp2
# link the formula to replace the system cURL
brew link curl --force
curl -I -k --http2 https://localhost:8080/hello
HTTP Connector 추가하기
@Bean
public ServletWebServerFactory serverFactory() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addAdditionalTomcatConnectors(createStandardConnector());
return tomcat;
}
private Connector createStandardConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(8080);
return connector;
}
application.properties
기존 HTTPS 가 적용된 포트는 8443으로 변경
server.port=8443
HTTP2 활성화
78. Embedded Web Servers
Each Spring Boot web application includes an embedded web server. This feature leads to a number of how-to questions, including how to change the embedded server and how to configure the embedded server. This section answers those questions. 78.2 Disabling
docs.spring.io
HTTP2를 설정하려면 반드시 HTTPS를 먼저 설정을 한다음 해야된다
server.http2.enabled=true
Undertow의 경우 HTTPS만 설정되어있으면 추가 설정하지 않아도 HTTP2가 활성화됨
TOMCAT 에서 HTTP2 설정
78. Embedded Web Servers
Each Spring Boot web application includes an embedded web server. This feature leads to a number of how-to questions, including how to change the embedded server and how to configure the embedded server. This section answers those questions. 78.2 Disabling
docs.spring.io
Tomcat 8.5에서는 설정이 너무 번거로움 Tomcat 9 이상에서는 별 다른 설정이 필요없음
위에 exclude tomcat 설정을 해제 하고 이렇게 셋팅하면 된다
Intellij 설정
아래 위치들의 Java 버전을 변경
- File - Project Structure - Project
- File - Project Structure - Modules - Dependencies
'개발강의정리 > Spring' 카테고리의 다른 글
[스프링 부트 개념과 활용] 4-1. 스프링 부트 활용 소개 (0) | 2019.10.21 |
---|---|
[스프링 부트 개념과 활용] 3-8. 독립적으로 실행 가능한 JAR (0) | 2019.10.20 |
[스프링 부트 개념과 활용] 3-6. 내장 웹 서버 응용 1부: 컨테이너와 포트 (0) | 2019.10.18 |
[스프링 부트 개념과 활용] 3-5. 내장 웹 서버 이해 (0) | 2019.10.17 |
[스프링 부트 개념과 활용] 3-4. 자동 설정 만들기 (0) | 2019.10.16 |
댓글