跳到主要内容

HTTPS 配置指南

单机版支持 HTTPS 访问

1、准备

  • 七层代理(Nginx, LB 等)

  • 访问域名及证书

2、操作

1、执行 cd /data/tencent/weda 切换到安装目录;

2、执行 vim config.yaml 编辑 config.yaml 文件;

3、修改 config.yaml 内容如下:

domainProtocol: https
domain: <替换成 https 访问域名>
domainPort: 443
serverPort: 8080

4、在当前目录下执行 ./upgrade.sh 重启服务使配置生效

5、配置代理转发(我们这里以 Nginx 为例, LB 配置根据实际情况配置证书即可, 转发到 http://<VM IP>:8080 即可.)

nginx.conf

# 全局配置
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

# 事件模块配置
events {
worker_connections 1024;
}

# HTTP模块配置
http {
# MIME类型映射
include /etc/nginx/mime.types;
default_type application/octet-stream;

# 日志格式
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

# 访问日志
access_log /var/log/nginx/access.log main;

# Gzip压缩
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;

# body 大小必须设置, 否则发布应用会报错
client_max_body_size 500m;
client_body_buffer_size 10m;
gzip_types application/javascript application/json application/xml
application/xhtml+xml text/css text/plain text/xml;

server {
listen 443 ssl;
server_name <替换成访问域名>; # <- Change this to match server_name above

# SSL证书和私钥
ssl_certificate /etc/nginx/certs/server.crt; # <- Change this to your .crt file name
ssl_certificate_key /etc/nginx/certs/server.key; # <- Change this to your .key file name

# 根路径代理
location / {
proxy_pass http://<替换成 VM IP 地址>:8080; # <== weda service ip
}
}
}

证书存放路径

/etc/nginx
├── certs
│ ├── server.cert
│ └── server.key
└── nginx.conf

6、规则配置完成,且配置域名解析之后,使用 https://<访问域名>/dev/ 访问即可