增加对https的支持

This commit is contained in:
panlinlin 2021-04-19 11:13:39 +08:00
parent 8af9159ebd
commit 9117294d0a
2 changed files with 15 additions and 2 deletions

View File

@ -61,6 +61,9 @@ public class ZLMRunner implements CommandLineRunner {
@Value("${media.autoConfig}") @Value("${media.autoConfig}")
private boolean autoConfig; private boolean autoConfig;
@Value("${server.ssl.enabled}")
private boolean sslEnabled;
@Autowired @Autowired
private ZLMRESTfulUtils zlmresTfulUtils; private ZLMRESTfulUtils zlmresTfulUtils;
@ -116,8 +119,8 @@ public class ZLMRunner implements CommandLineRunner {
if (StringUtils.isEmpty(mediaHookIp)) { if (StringUtils.isEmpty(mediaHookIp)) {
mediaHookIp = sipIP; mediaHookIp = sipIP;
} }
String protocol = sslEnabled ? "https" : "http";
String hookPrex = String.format("http://%s:%s/index/hook", mediaHookIp, serverPort); String hookPrex = String.format("%s://%s:%s/index/hook", protocol, mediaHookIp, serverPort);
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("api.secret",mediaSecret); // -profile:v Baseline param.put("api.secret",mediaSecret); // -profile:v Baseline
param.put("ffmpeg.cmd","%s -fflags nobuffer -rtsp_transport tcp -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s"); param.put("ffmpeg.cmd","%s -fflags nobuffer -rtsp_transport tcp -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s");

View File

@ -31,6 +31,16 @@ spring:
# [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 # [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口
server: server:
port: 18080 port: 18080
# [可选] HTTPS配置 默认不开启
ssl:
# [可选] 是否开启HTTPS访问
enabled: false
# [可选] 证书文件路径放置在resource/目录下即可修改xxx为文件名
key-store: classpath:xxx.jks
# [可选] 证书密码
key-password: password
# [可选] 证书类型, 默认为jks根据实际修改
key-store-type: JKS
# 作为28181服务器的配置 # 作为28181服务器的配置
sip: sip: