Files
sso/deploy/nginx.conf
T
adminandClaude Code f3df8b93a5 fix(deploy): build 时修正精简版 Dockerfile / nginx.conf 残留
**影响**:build 阶段 (`bash deploy/build.sh --no-push`) 报 Dockerfile COPY 错误,
镜像未生成。修正后镜像 `ipass-sso-v0.6.0` 本地构建成功,nginx -t 通过、
容器启动正常、`/admin/` 与 `/.well-known/openid-configuration` 双 200。

**改动**:
- `deploy/Dockerfile`:
  - 删 `COPY deploy/custom/ ...`(精简版无 deploy/custom/ 目录)
  - 删 `COPY deploy/legacy/ ...`(精简版无 deploy/legacy/ 目录)
  - `EXPOSE 18098 18099` → `EXPOSE 18098`(精简版没 LLM 数据面,18099 用不到)
- `deploy/nginx.conf`:
  - 删 `location /static/custom/ {...}`(精简版无 static-custom/)
  - 删 `location /legacy/ {...}`(精简版不集成老管理台)

**设计**:上一步 commit 漏了 Dockerfile / nginx.conf 与文件系统的同步:
rsync 自 ipass-all 时连带 rsync 来了 deploy/custom/ 与 deploy/legacy/,
后续又手动 rm 掉了这两个目录,但 Dockerfile 里的 COPY 与 nginx.conf
里的 alias location 没同步清。

Co-Authored-By: Claude Code <[email protected]>
2026-09-30 12:05:19 +08:00

142 lines
6.0 KiB
Nginx Configuration File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ============================================================================
# ipass-sso 容器运行配置(精简版:身份/IdP + 管理台)
#
# 从 ipass-all/deploy/nginx.conf 派生的 SSO-only 版(2026-09-30 拍板):
# 剔除了 domain / llm / apix / cache / waf 5 个插件对应的 location 与
# 整个 LLM 数据面 server、动态域名 server;只保留身份 / 管理台 / API 端点。
#
# 指令清单 = 本仓 gateway 注册的 4 条:
# main : ipass_state / ipass_data_dir
# loc : ipass_api / sso_iap
#
# 非 root 适配(k8s 租户准入强制 runAsUser=10106):
# pid/lock/temp 全部挪 /tmp
# ============================================================================
worker_processes auto;
error_log /usr/local/nginx/logs/error.log info;
pid /tmp/nginx/nginx.pid;
lock_file /tmp/nginx/nginx.lock;
load_module /usr/local/nginx/modules/libipass_sso_gateway.so;
# 模块读取的 env 白名单(nginx 默认剥离全部环境变量;漏一条 = worker 里恒空)
env ADMIN_INIT_PASSWORD;
env OAUTH_SIGNING_SECRET;
env OAUTH_ISSUER;
env OAUTH_COOKIE_DOMAIN;
env SYNC_DINGTALK_URL;
env SYNC_WORKWECHAT_URL;
env SYNC_FEISHU_URL;
env PASSWORD_RESET_TOKEN_SINK;
env PASSWORD_RESET_TTL;
events {
worker_connections 2048;
}
http {
include /usr/local/nginx/conf/mime.types;
default_type application/json; # 业务侧默认 JSON,静态页在对应 location 覆盖
sendfile on;
keepalive_timeout 65;
# ------------------------------------------------------------------
# 非 root 适配:临时目录默认在编译前缀下(root 属主),10106 建不了
# ------------------------------------------------------------------
client_body_temp_path /tmp/nginx/client_body;
proxy_temp_path /tmp/nginx/proxy;
fastcgi_temp_path /tmp/nginx/fastcgi;
# ------------------------------------------------------------------
# 日志:带身份维度(WAF/缓存/域名等插件字段在精简版省略),排障不翻模块日志
# ------------------------------------------------------------------
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" "$http_user_agent" '
'"$upstream_addr" "$upstream_status" "$upstream_response_time" '
'auth_user=$auth_user';
access_log /usr/local/nginx/logs/access.log main;
# ------------------------------------------------------------------
# 内核:共享内存 + 数据目录(必须显式,理由见文件头)
# ------------------------------------------------------------------
ipass_state state 16m; # 身份会话+账号 Key(精简版无域名/用量/缓存/WAF)
ipass_data_dir /usr/local/nginx/data;
# ==================================================================
# 主 server(NodePort 30082):管理台 + IdP 全部端点
# ==================================================================
# 证书:多域名证书(SAN 含 *.mayishangshu.cn / mayishangshu.cn 等,
# 2026-11-04 到期);证书放**数据目录**(PVC:/usr/local/nginx/data/tls/),
# 换证书 = 换文件 + 重启,不用重打镜像。
# ⚠️ nginx 同一端口不能既明文又 TLS:18098 = TLS only(NodePort 30082);
# 明文入口 = 18097(同端口)。
ssl_certificate /usr/local/nginx/data/tls/fullchain.cer;
ssl_certificate_key /usr/local/nginx/data/tls/tls.key;
ssl_trusted_certificate /usr/local/nginx/data/tls/ca.cer;
ssl_protocols TLSv1.2 TLSv1.3;
server {
listen 18098 ssl default_server; # TLS
listen 18097; # 明文(内网调试)
server_name _;
absolute_redirect off;
port_in_redirect off;
# 管理台核心壳(ipass-core www dist)+ sso 管理页
root /usr/local/nginx/www;
index index.html;
client_max_body_size 10m;
client_body_buffer_size 1m;
# ---- 管理/身份 API(content 阶段读体后按 PLUGINS 顺序分发)----
# 认领方:sso(身份端点/OIDC/SCIM/CAS/门户)+ core(账号/插件启停注册表)
location /api/ {
ipass_api on;
}
# OIDC/身份协议端点挂在根路径(/oauth/* /login /logout /userinfo
# /.well-known/* /apps /reset /cas/*),由 sso 插件认领
location / {
ipass_api on;
}
# ---- 管理台静态资源(这些 location 不开 ipass_api:静态文件走 nginx)----
location = / {
return 302 /admin/;
}
location = /admin {
return 302 /admin/;
}
location = /index.html {
add_header Cache-Control "no-store" always;
}
location /admin/ {
try_files $uri $uri/ /index.html; # SPA history 深链兜底
add_header Cache-Control "no-store" always;
}
# 插件面板路由(/plugin-<name>)走壳 SPA:直链/刷新时回 index.html
location /plugin- {
try_files $uri /index.html;
add_header Cache-Control "no-store" always;
}
# 壳内置面板路由(/manage/*,网关管理三页)同上
location /manage/ {
try_files $uri /index.html;
add_header Cache-Control "no-store" always;
}
location /assets/ {
add_header Cache-Control "no-store" always;
}
# 插件管理页 UMD 产物(壳按 /static/plugins/<name>/dist/<name>-admin.umd.js 拉取)
location /static/plugins/ {
alias /usr/local/nginx/static-plugins/;
add_header Cache-Control "no-store" always;
}
# 装配层自定义页清单(精简版不挂自定义页,无 /static/custom/)
# 老管理台多页应用(精简版不集成老管理台,无 /legacy/)
}
}