fix: http, https 설정 반영

main
Jonguk. Lim 3 months ago
parent c934d35723
commit e39928b750

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

@ -2,6 +2,9 @@
# local 설정
#-----------------------------------------------------------------------
spring:
# profiles:
# include:
# - https
datasource:
hikari:
# 9 server
@ -56,7 +59,7 @@ app:
#swagger-url: 'http://localhost:${server.port}${server.servlet.context-path:}/'
# Spring Security cors 설정 :: CorsConfiguration 설정 값
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:
root:

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

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

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

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

Loading…
Cancel
Save