test
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
# 2. 配置 GOPROXY(自动测速选最快节点)
|
||||
# 3. 安装 Node.js / npm(前端依赖)
|
||||
# 4. 安装 Docker(基础设施容器)
|
||||
# 5. 安装 Nginx 并写入 PC/OpenIM 反代(:80 → 10001/10002/10008,见 nginx/openim-pc-proxy.conf)
|
||||
# 5. 安装 Nginx 并写入 PC/OpenIM 反代(:80 API 网关,:443 PC/API/WS + COOP/COEP)
|
||||
# 6. 写入 /etc/profile.d/deploy-env.sh(永久生效)
|
||||
#
|
||||
# 用法:
|
||||
@@ -244,7 +244,7 @@ _install_docker() {
|
||||
}
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# 5. Nginx — PC / OpenIM 统一入口(HTTP :80,反代本机 10001/10002/10008)
|
||||
# 5. Nginx — PC / OpenIM 统一入口(HTTP :80 / HTTPS :443)
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
_install_pc_nginx_proxy() {
|
||||
step "安装 Nginx 并配置 OpenIM/PC 反代"
|
||||
@@ -258,6 +258,16 @@ _install_pc_nginx_proxy() {
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
local conf_src="${script_dir}/nginx/openim-pc-proxy.conf"
|
||||
local conf_name="openim-pc-proxy.conf"
|
||||
local deploy_ip="${DEPLOY_TEST_IP:-54.116.29.247}"
|
||||
local ssl_dir="/etc/nginx/ssl"
|
||||
local ssl_key="${ssl_dir}/openim-pc-proxy-selfsigned.key"
|
||||
local ssl_crt="${ssl_dir}/openim-pc-proxy-selfsigned.crt"
|
||||
|
||||
if [[ -f "$ENV_FILE" ]]; then
|
||||
# shellcheck source=/dev/null
|
||||
source "$ENV_FILE"
|
||||
deploy_ip="${DEPLOY_TEST_IP:-$deploy_ip}"
|
||||
fi
|
||||
|
||||
if [[ ! -f "$conf_src" ]]; then
|
||||
error " 找不到配置: $conf_src"
|
||||
@@ -267,17 +277,47 @@ _install_pc_nginx_proxy() {
|
||||
if ! _has nginx; then
|
||||
if _has apt-get; then
|
||||
apt-get update -y
|
||||
apt-get install -y nginx
|
||||
apt-get install -y nginx openssl
|
||||
elif _has dnf; then
|
||||
dnf install -y nginx
|
||||
dnf install -y nginx openssl
|
||||
elif _has yum; then
|
||||
yum install -y nginx
|
||||
yum install -y nginx openssl
|
||||
else
|
||||
error " 未检测到 apt/dnf/yum,请先手动安装 nginx"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! _has openssl; then
|
||||
if _has apt-get; then
|
||||
apt-get update -y
|
||||
apt-get install -y openssl
|
||||
elif _has dnf; then
|
||||
dnf install -y openssl
|
||||
elif _has yum; then
|
||||
yum install -y openssl
|
||||
else
|
||||
error " 未安装 openssl,无法生成 HTTPS 自签名证书"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$ssl_dir"
|
||||
if [[ ! -s "$ssl_key" ]] || [[ ! -s "$ssl_crt" ]]; then
|
||||
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
|
||||
-keyout "$ssl_key" \
|
||||
-out "$ssl_crt" \
|
||||
-subj "/CN=${deploy_ip}" \
|
||||
-addext "subjectAltName=IP:${deploy_ip},DNS:localhost" >/dev/null 2>&1 || \
|
||||
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
|
||||
-keyout "$ssl_key" \
|
||||
-out "$ssl_crt" \
|
||||
-subj "/CN=${deploy_ip}" >/dev/null 2>&1
|
||||
chmod 0600 "$ssl_key"
|
||||
chmod 0644 "$ssl_crt"
|
||||
success " 已生成 HTTPS 自签名证书: $ssl_crt"
|
||||
fi
|
||||
|
||||
if [[ -d /etc/nginx/sites-available ]]; then
|
||||
install -m 0644 "$conf_src" "/etc/nginx/sites-available/${conf_name}"
|
||||
mkdir -p /etc/nginx/sites-enabled
|
||||
@@ -303,9 +343,10 @@ _install_pc_nginx_proxy() {
|
||||
systemctl restart nginx
|
||||
|
||||
success " Nginx 反代已启用(配置: $conf_src)"
|
||||
info " 请放行 TCP 80;curl -sS http://127.0.0.1/nginx-health 应返回 ok"
|
||||
info " 纯 IP 访问 :80 为 API 网关;若 nginx -t 报 duplicate default_server,请从其它站点配置中去掉 default_server"
|
||||
info " .env.deploy-test 中 PC_BACKEND_ORIGIN=http://<公网IP>(与 DEPLOY_TEST_IP 一致)"
|
||||
info " 请放行 TCP 80/443;curl -k -sS https://127.0.0.1/nginx-health 应返回 ok"
|
||||
info " 纯 IP 访问 :80 为 API 网关;HTTPS :443 会代理 PC dev server + API + WebSocket,并启用 COOP/COEP"
|
||||
info " 为避免 OpenIM WASM DB worker 在 http://公网IP:5173 下超时,建议 .env.deploy-test 设置 PC_BACKEND_ORIGIN=https://${deploy_ip}"
|
||||
info " 浏览器打开 https://${deploy_ip}/(首次访问需接受自签名证书)"
|
||||
}
|
||||
|
||||
# all 时非 root 则跳过(不中断 Go/Node/Docker)
|
||||
|
||||
Reference in New Issue
Block a user