支持https
修改router header 模式 bug
This commit is contained in:
parent
bccdfab4ba
commit
8312736200
@ -43,6 +43,7 @@ import io.vertx.core.http.HttpClient;
|
||||
import io.vertx.core.http.HttpMethod;
|
||||
import io.vertx.core.http.HttpServer;
|
||||
import io.vertx.core.http.HttpServerOptions;
|
||||
import io.vertx.core.net.JksOptions;
|
||||
import io.vertx.core.spi.cluster.ClusterManager;
|
||||
import io.vertx.ext.web.Route;
|
||||
import io.vertx.ext.web.Router;
|
||||
@ -82,7 +83,8 @@ public class AppConfigHandler {
|
||||
|
||||
// 负载均衡路由类型 appCode:apiCode - routerType
|
||||
// 执行流程 routerType= <br/>
|
||||
// 1、serviceNodel="NORMAL", serviceNodel="ROUTE" and RouteType = "WEIGHT_ROUTE" <br/>
|
||||
// 1、serviceNodel="NORMAL", serviceNodel="ROUTE" and RouteType = "WEIGHT_ROUTE"
|
||||
// <br/>
|
||||
// return LOADBALANCING_MAP
|
||||
// 2、serviceNodel="ROUTE", RouteType = "HEADER_ROUTE" <br/>
|
||||
// return APICODE_CONFIG_ROUTERCONENT_MAP
|
||||
@ -95,7 +97,6 @@ public class AppConfigHandler {
|
||||
// 禁用appCode
|
||||
private static ConcurrentHashSet<String> DISABLED_APPCODE = new ConcurrentHashSet<String>();
|
||||
|
||||
|
||||
public static Integer routerType(String key) {
|
||||
return APICODE_CONFIG_ROUTERTYPE_MAP.get(key) != null ? APICODE_CONFIG_ROUTERTYPE_MAP.get(key) : 1;
|
||||
}
|
||||
@ -301,9 +302,9 @@ public class AppConfigHandler {
|
||||
}
|
||||
|
||||
// app router负载均衡
|
||||
int routerType = 1;
|
||||
List<RouteContent> routeContentList = null;
|
||||
for (SacService sacService : appConfig.getService()) {
|
||||
int routerType = 1;
|
||||
List<Node> nodeList = new ArrayList<>();
|
||||
// 获取service模式
|
||||
if (StringUtils.equals(sacService.getServiceModel(), "NORMAL")) {
|
||||
@ -501,6 +502,10 @@ public class AppConfigHandler {
|
||||
// 创建HTTP监听
|
||||
// 所有ip都能访问
|
||||
HttpServerOptions httpServerOptions = new HttpServerOptions().setHost("0.0.0.0");
|
||||
if (sacVertxConfig.isSSLs()) {
|
||||
httpServerOptions.setSsl(true)
|
||||
.setKeyStoreOptions(new JksOptions().setPassword("changeit").setPath("keystore.jks"));
|
||||
}
|
||||
HttpServer server = VERTX.createHttpServer(httpServerOptions);
|
||||
Router mainHttpRouter = Router.router(VERTX);
|
||||
Integer serverPort = vertxConfig.getPort() == null ? sacVertxConfig.getPort() : vertxConfig.getPort();
|
||||
@ -563,10 +568,9 @@ public class AppConfigHandler {
|
||||
} else {
|
||||
route = mainHttpRouter.route();
|
||||
}
|
||||
route.handler(ParameterCheckHandler.create())
|
||||
.handler(AppRateLimitHandler.create(rateLimitModel)).handler(ApiRateLimitHandler.create(rateLimitModel))
|
||||
.handler(BodyHandler.create()).handler(ProxyHandler.create(mainWebClient, proxy))
|
||||
.failureHandler(RestfulFailureHandler.create());
|
||||
route.handler(ParameterCheckHandler.create()).handler(AppRateLimitHandler.create(rateLimitModel))
|
||||
.handler(ApiRateLimitHandler.create(rateLimitModel)).handler(BodyHandler.create())
|
||||
.handler(ProxyHandler.create(mainWebClient, proxy)).failureHandler(RestfulFailureHandler.create());
|
||||
// mainHttpRouter.route().handler(ProxyHandler.create(mainWebClient, proxy));
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,9 @@ public class SacVertxConfig {
|
||||
@Value("${server.vertx.rpcUri:/rpc}")
|
||||
private String rpcUri;
|
||||
|
||||
@Value("${server.vertx.isSSL:false}")
|
||||
private boolean isSSLs;
|
||||
|
||||
@Value("${server.vertx.deploymentMode:1}")
|
||||
private Integer deploymentMode;
|
||||
|
||||
|
@ -3,8 +3,6 @@ package com.sf.vertx.utils;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.sf.vertx.api.pojo.Node;
|
||||
import com.sf.vertx.api.pojo.RouteContent;
|
||||
import com.sf.vertx.arithmetic.roundRobin.SacLoadBalancing;
|
||||
|
@ -3,12 +3,13 @@ server:
|
||||
vertx:
|
||||
deploymentMode: 1 # 1:单机 2:集群
|
||||
requestModel: 2 # 1: 客户端传递uri. 2: uri vertx代理,不对客户端暴露uri
|
||||
isSSL: false # vertx https或者http启动, ssl 证书有过期时间
|
||||
rpcUri: /rpc
|
||||
sacResponseHeaderKey: sacErrorCode
|
||||
environment: dev
|
||||
server:
|
||||
default:
|
||||
port: 80
|
||||
port: 80 # https端口配置为443
|
||||
cluster:
|
||||
ip: 127.0.0.1
|
||||
clusterName: sac-dev
|
||||
|
BIN
sf-vertx/src/main/resources/cacerts.jks
Normal file
BIN
sf-vertx/src/main/resources/cacerts.jks
Normal file
Binary file not shown.
BIN
sf-vertx/src/main/resources/keystore.jks
Normal file
BIN
sf-vertx/src/main/resources/keystore.jks
Normal file
Binary file not shown.
BIN
sf-vertx/src/main/resources/server.cer
Normal file
BIN
sf-vertx/src/main/resources/server.cer
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user