Commit aceb0832 authored by xuchentao's avatar xuchentao

feat: enable production HTTPS

parent 1a7d57d2
Pipeline #452 failed with stage
in 16 seconds
......@@ -11,7 +11,7 @@ variables:
PM2_BIN: "/usr/bin/pm2"
PM2_HOME_DIR: "/root/.pm2"
PM2_USE_SUDO: "1"
PUBLIC_HOST: "101.126.10.129"
PUBLIC_HOST: "www.sumeiqiao.com"
stages:
- deploy
......
......@@ -150,7 +150,7 @@ CMS_BUILD_LOCK=/root/sumeiqiao/shared/site-build.lock
- PM2 应用名:`sumeiqiao`
- 服务端口:`8789`
- Nginx 配置:`/etc/nginx/conf.d/sumeiqiao.conf`
- 公网入口:`101.126.10.129:80`
- 公网入口:`https://www.sumeiqiao.com``sumeiqiao.com` 同时支持 HTTPS)
如果服务器实际路径或 PM2 应用名不同,只修改 `.gitlab-ci.yml` 顶部变量即可。脚本只会对 `APP_NAME` 指定的一个 PM2 进程执行 `describe``delete``start`,不会停止、重启或保存其他 PM2 项目。
......
# 塑美俏官网 Nginx 配置
# 通过服务器公网 IP 临时访问,反向代理到本机 8789 端口。
# sumeiqiao.com / www.sumeiqiao.com 正式 HTTPS 入口,反向代理到本机 8789 端口。
server {
listen 80;
server_name 101.126.10.129;
listen [::]:80;
server_name sumeiqiao.com www.sumeiqiao.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name sumeiqiao.com www.sumeiqiao.com;
ssl_certificate /etc/nginx/certs/sumeiqiao.com.fullchain.pem;
ssl_certificate_key /etc/nginx/certs/sumeiqiao.com.certkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
# 图片上限为 20MB,JSON 中的 Base64 数据会额外增大请求体。
client_max_body_size 28m;
......
......@@ -161,6 +161,8 @@ test -f "$nginx_source"
sudo -n /usr/bin/install -o root -g root -m 0644 "$nginx_source" "$nginx_target"
sudo -n /usr/sbin/nginx -t
sudo -n /usr/bin/systemctl reload nginx
curl --fail --silent --show-error --max-time 5 --header "Host: $public_host" http://127.0.0.1/ >/dev/null
curl --fail --silent --show-error --max-time 5 \
--resolve "${public_host}:443:127.0.0.1" \
"https://${public_host}/" >/dev/null
echo "[deploy] 部署成功:$current_dir$commit_sha)"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment