fix: http, https 설정 반영

main
Jonguk. Lim 3 months ago
parent c934d35723
commit e39928b750

@ -2,6 +2,9 @@
# local 설정 # local 설정
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
spring: spring:
# profiles:
# include:
# - https
datasource: datasource:
hikari: hikari:
# 9 server # 9 server

@ -2,6 +2,9 @@
# local 설정 # local 설정
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
spring: spring:
# profiles:
# include:
# - https
datasource: datasource:
hikari: hikari:
# 9 server # 9 server
@ -56,7 +59,7 @@ app:
#swagger-url: 'http://localhost:${server.port}${server.servlet.context-path:}/' #swagger-url: 'http://localhost:${server.port}${server.servlet.context-path:}/'
# Spring Security cors 설정 :: CorsConfiguration 설정 값 # Spring Security cors 설정 :: CorsConfiguration 설정 값
cors: cors:
allowed-origins: http://localhost:8080, https://localhost:9443, http://${app.api-ip}:8080, http://localhost:8082, http://${app.api-ip}:8082 allowed-origins: http://localhost:8082, https://localhost:9443, http://${app.api-ip}:8082, http://${app.api-ip}:9443
data: data:
root: root:

@ -33,6 +33,9 @@ app:
post: /post/rcv/ post: /post/rcv/
spring: spring:
# spring.profiles.include 유지(2.4이후 spring.config.import)
config:
use-legacy-processing: true
main: main:
# 순환참조 에러 무시 # 순환참조 에러 무시
allow-circular-references: true allow-circular-references: true
@ -40,10 +43,7 @@ spring:
file: ${app.data.root.path}/${app.name}.pid file: ${app.data.root.path}/${app.name}.pid
profiles: profiles:
active: '@springProfilesActive@' active: '@springProfilesActive@'
# core의 application-common.yml과 application-auth.yml include
include: include:
- https
- common - common
- auth - auth
- app - app

@ -1,10 +1,15 @@
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# local 설정 # local 설정
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
server: # https 활성화시 comment 해제
port: 9443 #server:
http: 8082 # port: 9443
# http: 8082
spring: spring:
# profiles:
# include:
# - https
datasource: datasource:
# =============== p6spy =============================== # =============== p6spy ===============================
#driver-class-name: org.mariadb.jdbc.Driver #driver-class-name: org.mariadb.jdbc.Driver
@ -67,7 +72,8 @@ app:
#swagger-url: 'http://localhost:${server.port}${server.servlet.context-path:}/' #swagger-url: 'http://localhost:${server.port}${server.servlet.context-path:}/'
# Spring Security cors 설정 :: CorsConfiguration 설정 값 # Spring Security cors 설정 :: CorsConfiguration 설정 값
cors: cors:
allowed-origins: http://localhost:8080 allowed-origins: http://localhost:8081, https://localhost:8443
# allowed-origins: http://localhost:8081, https://localhost:8443, http://localhost:8082, https://localhost:9443
data: data:
root: root:
#path: /Users/minuk/data #path: /Users/minuk/data

@ -33,6 +33,9 @@ app:
post: /post/rcv/ post: /post/rcv/
spring: spring:
# spring.profiles.include 유지(2.4이후 spring.config.import)
config:
use-legacy-processing: true
main: main:
# 순환참조 에러 무시 # 순환참조 에러 무시
allow-circular-references: true allow-circular-references: true
@ -43,7 +46,6 @@ spring:
# core의 application-common.yml과 application-auth.yml include # core의 application-common.yml과 application-auth.yml include
include: include:
- https
- common - common
- auth - auth
- app - app

@ -2,11 +2,13 @@ package kr.xit.core.spring.config.support;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import org.apache.catalina.Context; import org.apache.catalina.Context;
import org.apache.catalina.connector.Connector; import org.apache.catalina.connector.Connector;
import org.apache.tomcat.util.descriptor.web.SecurityCollection; import org.apache.tomcat.util.descriptor.web.SecurityCollection;
@ -38,15 +40,21 @@ import org.springframework.context.annotation.Configuration;
* *
* </pre> * </pre>
*/ */
@ConditionalOnProperty(value = "server.http") @ConditionalOnProperty(value = "server.ssl.enabled", havingValue = "true", matchIfMissing = false)
@Configuration @Configuration
public class HttpsConnectorConfig { public class HttpsConnectorConfig {
@Value("${server.port}") @Value("${server.port}")
private int SSL_PORT; private int SERVER_PORT;
@Value("${server.http}") @Value("${server.http}")
private int HTTP_PORT; private int HTTP_PORT;
@Value("${server.ssl.redirect}")
@Value("${server.ssl.enabled:false}")
private boolean sslEnabled;
@Value("${server.ssl.redirect:false}")
private boolean SSL_REDIRECT; private boolean SSL_REDIRECT;
@Bean @Bean
public ServletWebServerFactory servletContainer() { public ServletWebServerFactory servletContainer() {
@ -80,8 +88,9 @@ public class HttpsConnectorConfig {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http"); connector.setScheme("http");
connector.setSecure(false); connector.setSecure(false);
connector.setPort(HTTP_PORT); if(sslEnabled) connector.setPort(HTTP_PORT);
if(SSL_REDIRECT) connector.setRedirectPort(SSL_PORT); else connector.setPort(SERVER_PORT);
if(SSL_REDIRECT) connector.setRedirectPort(SERVER_PORT);
return connector; return connector;
} }

Loading…
Cancel
Save