Provide authenticated IP HTTPS access and clarify server UI
This commit is contained in:
@@ -14,6 +14,8 @@ if not cert.exists():
|
|||||||
if not Path(replacement, 'fullchain.pem').exists():
|
if not Path(replacement, 'fullchain.pem').exists():
|
||||||
raise SystemExit('Install a valid origin certificate before configuring HTTPS')
|
raise SystemExit('Install a valid origin certificate before configuring HTTPS')
|
||||||
text = text.replace('/etc/letsencrypt/live/kaoyan.fjayson.com/', replacement)
|
text = text.replace('/etc/letsencrypt/live/kaoyan.fjayson.com/', replacement)
|
||||||
|
if Path('/etc/letsencrypt/live/186.241.68.230/fullchain.pem').exists():
|
||||||
|
text += '\n' + (root / 'nginx-ip-origin.conf').read_text()
|
||||||
Path('/etc/nginx/sites-available/kaoyan-studio').write_text(text)
|
Path('/etc/nginx/sites-available/kaoyan-studio').write_text(text)
|
||||||
PY
|
PY
|
||||||
ln -sfn /etc/nginx/sites-available/kaoyan-studio /etc/nginx/sites-enabled/kaoyan-studio
|
ln -sfn /etc/nginx/sites-available/kaoyan-studio /etc/nginx/sites-enabled/kaoyan-studio
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# An authenticated HTTPS entry while the CDN domain is being configured.
|
||||||
|
# Uses the server's separately renewed IP certificate and an unused port.
|
||||||
|
server {
|
||||||
|
listen 9443 ssl;
|
||||||
|
listen [::]:9443 ssl;
|
||||||
|
server_name 186.241.68.230;
|
||||||
|
ssl_certificate /etc/letsencrypt/live/186.241.68.230/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/186.241.68.230/privkey.pem;
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
client_max_body_size 100m;
|
||||||
|
auth_basic "Kaoyan Workbench";
|
||||||
|
auth_basic_user_file /etc/nginx/kaoyan-studio.htpasswd;
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:8765;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto https;
|
||||||
|
proxy_read_timeout 120s;
|
||||||
|
proxy_hide_header Cache-Control;
|
||||||
|
add_header Cache-Control "private, no-store" always;
|
||||||
|
add_header X-Content-Type-Options nosniff always;
|
||||||
|
add_header X-Frame-Options DENY always;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Debian 12 服务器部署
|
# Debian 12 服务器部署
|
||||||
|
|
||||||
服务器:186.241.68.230;域名:https://kaoyan.fjayson.com。部署分支 `feat/debian-server`,应用监听回环 8765,Nginx 提供访问认证;域名通过用户的 CDN 回源。账号密码单独交付,不放入 Git。浏览器第一次访问会提示输入工作台访问账号,这与学信网账号不同。
|
服务器:186.241.68.230;域名:https://kaoyan.fjayson.com;备用入口:https://186.241.68.230:9443。部署分支 `feat/debian-server`,应用监听回环 8765,Nginx 提供访问认证;域名通过用户的 CDN 回源。备用入口使用有效 IP 证书,与域名共用访问账号。账号密码单独交付,不放入 Git。浏览器第一次访问会提示输入工作台访问账号,这与学信网账号不同。
|
||||||
|
|
||||||
## 目录与服务
|
## 目录与服务
|
||||||
|
|
||||||
@@ -42,11 +42,17 @@ python -m studio.migrate /path/to/studio-snapshot.db --config /path/to/private-m
|
|||||||
|
|
||||||
正式快照:27,901 条目录、0 条历史线、559 条院校索引、4 个任务、4,302 个断点、4,319 条日志;当前全国任务含 4,282 个完成单元。数据仍处于 2027 招生目录阶段,历史数据不会因部署自动出现。逐表内容校验结果位于服务器 `/opt/kaoyan-studio-deploy/migration-verification.json`。
|
正式快照:27,901 条目录、0 条历史线、559 条院校索引、4 个任务、4,302 个断点、4,319 条日志;当前全国任务含 4,282 个完成单元。数据仍处于 2027 招生目录阶段,历史数据不会因部署自动出现。逐表内容校验结果位于服务器 `/opt/kaoyan-studio-deploy/migration-verification.json`。
|
||||||
|
|
||||||
|
目录、历史线、任务、断点和日志逐表内容一致。应用启动载入内置院校索引时更新了两个索引名称:82605 更新为“冶金自动化研究设计院”,83401 更新为“中国石油勘探开发研究院”;目录记录中的原始名称与内容均保留,因此运行后的院校索引全表哈希不同。迁移 Cookie 的实际第二页验证返回要求登录,必须在页面更新 Cookie 后再恢复原暂停任务。
|
||||||
|
|
||||||
## HTTPS 与 CDN
|
## HTTPS 与 CDN
|
||||||
|
|
||||||
CDN 回源地址为该服务器,应用保持原始 Host `kaoyan.fjayson.com`,使用 HTTPS 443 回源,并转发 Authorization、请求方法与正文。禁止缓存工作台 HTML/API,源站已返回 `Cache-Control: private, no-store`。域名的浏览器证书由 CDN 提供;源站优先使用域名证书,也可使用当前有效的 IP 证书用于 CDN IP 回源。
|
CDN 回源地址为该服务器,应用保持原始 Host `kaoyan.fjayson.com`,使用 HTTPS 443 回源,并转发 Authorization、请求方法与正文。禁止缓存工作台 HTML/API,源站已返回 `Cache-Control: private, no-store`。域名的浏览器证书由 CDN 提供;源站优先使用域名证书,也可使用当前有效的 IP 证书用于 CDN IP 回源。
|
||||||
|
|
||||||
部署时 HTTP-01 的本地回源探测成功,但证书机构访问另一 CDN 节点收到 404,因此没有替换服务器现有证书。`configure-nginx.sh` 优先选择域名证书,否则保留现有源站 IP 证书。可通过 DNS-01 或修正全部 CDN 节点的挑战路径回源后申请域名证书,再重新运行配置脚本。源站证书仍由服务器已有证书维护流程管理。
|
部署时 HTTP-01 的本地回源探测成功,但证书机构访问另一 CDN 节点收到 404,因此没有替换服务器现有证书。`configure-nginx.sh` 优先选择域名证书,否则保留现有源站 IP 证书,并提供独立 9443 入口。可通过 DNS-01 或修正全部 CDN 节点的挑战路径回源后申请域名证书,再重新运行配置脚本。
|
||||||
|
|
||||||
|
源站 IP 证书使用服务器原有 `/opt/certbot-venv/bin/certbot` 5.8.0 维护,`certbot.timer` 已启用,续期后自动 reload Nginx。2026-10-11 对该 IP 证书执行 `renew --cert-name 186.241.68.230 --dry-run --no-random-sleep-on-renew` 成功。不要误用 `/usr/bin/certbot` 2.1.0 维护此 IP 证书。[Let's Encrypt 的 IP 证书说明](https://letsencrypt.org/2026/03/11/shorter-certs-certbot/)要求受支持的新版客户端。
|
||||||
|
|
||||||
|
HTTPS 域名若重定向到完全相同的网址,通常是 CDN 正在用 HTTP 回源源站的强制 HTTPS 入口。请改为 HTTPS 443 回源,保持请求 Host 与 TLS SNI 为 `kaoyan.fjayson.com`。源站当前证书的名称是 IP,供应商须支持按源站 IP 校验;若仅支持域名名称严格校验,则先取得域名证书。域名配置完成前可直接使用 9443 备用入口。
|
||||||
|
|
||||||
## 备份和升级
|
## 备份和升级
|
||||||
|
|
||||||
|
|||||||
+13
-9
@@ -195,6 +195,7 @@ export default function App() {
|
|||||||
const [tab, setTab] = useState<Tab>("overview");
|
const [tab, setTab] = useState<Tab>("overview");
|
||||||
const [overview, setOverview] = useState<Overview | null>(null);
|
const [overview, setOverview] = useState<Overview | null>(null);
|
||||||
const [majors, setMajors] = useState<Major[]>([]);
|
const [majors, setMajors] = useState<Major[]>([]);
|
||||||
|
const [serverMode, setServerMode] = useState(false);
|
||||||
const [version, setVersion] = useState(0);
|
const [version, setVersion] = useState(0);
|
||||||
const [notice, setNotice] = useState<{
|
const [notice, setNotice] = useState<{
|
||||||
message: string;
|
message: string;
|
||||||
@@ -210,10 +211,12 @@ export default function App() {
|
|||||||
Promise.all([
|
Promise.all([
|
||||||
api<Overview>("/overview", { signal: controller.signal }),
|
api<Overview>("/overview", { signal: controller.signal }),
|
||||||
api<Major[]>("/majors", { signal: controller.signal }),
|
api<Major[]>("/majors", { signal: controller.signal }),
|
||||||
|
api<{ platform: string }>("/health", { signal: controller.signal }),
|
||||||
])
|
])
|
||||||
.then(([o, m]) => {
|
.then(([o, m, health]) => {
|
||||||
setOverview(o);
|
setOverview(o);
|
||||||
setMajors(m);
|
setMajors(m);
|
||||||
|
setServerMode(health.platform === "linux");
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
if (e.name !== "AbortError") notify(e.message, true);
|
if (e.name !== "AbortError") notify(e.message, true);
|
||||||
@@ -247,7 +250,7 @@ export default function App() {
|
|||||||
<small>考研数据工作台</small>
|
<small>考研数据工作台</small>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<div className="nav-label">WORKSPACE / 本地工作区</div>
|
<div className="nav-label">WORKSPACE / {serverMode ? "服务器工作区" : "本地工作区"}</div>
|
||||||
<nav aria-label="主导航">
|
<nav aria-label="主导航">
|
||||||
{NAV.map((n) => (
|
{NAV.map((n) => (
|
||||||
<button
|
<button
|
||||||
@@ -263,7 +266,7 @@ export default function App() {
|
|||||||
</nav>
|
</nav>
|
||||||
<div className="sidebar-bottom">
|
<div className="sidebar-bottom">
|
||||||
<div className="local-indicator">
|
<div className="local-indicator">
|
||||||
<span /> 本机数据 · 独立保存
|
<span /> {serverMode ? "服务器数据 · 持续保存" : "本机数据 · 独立保存"}
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
把全国目录与历年考情
|
把全国目录与历年考情
|
||||||
@@ -283,7 +286,7 @@ export default function App() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="topbar-right">
|
<div className="topbar-right">
|
||||||
<span className="local-tag">
|
<span className="local-tag">
|
||||||
<ShieldCheck size={14} /> 本地运行
|
<ShieldCheck size={14} /> {serverMode ? "服务器运行" : "本地运行"}
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
className="icon-button"
|
className="icon-button"
|
||||||
@@ -303,7 +306,7 @@ export default function App() {
|
|||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
研途 · 数据以院校当年招生简章为准
|
研途 · 数据以院校当年招生简章为准
|
||||||
<span>全国招生目录 / 历年考情 / 本地工作区</span>
|
<span>全国招生目录 / 历年考情 / {serverMode ? "服务器工作区" : "本地工作区"}</span>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
{notice && (
|
{notice && (
|
||||||
@@ -1754,7 +1757,7 @@ function ProxyPanel({ notify }: { notify: Notify }) {
|
|||||||
</section>
|
</section>
|
||||||
<section className="card pool-controls">
|
<section className="card pool-controls">
|
||||||
<div className="card-title">
|
<div className="card-title">
|
||||||
<h2>本机代理池服务</h2>
|
<h2>{services?.manager === "systemd" ? "服务器代理池服务" : "本机代理池服务"}</h2>
|
||||||
<Badge tone={services?.api_ready ? "green" : ""}>
|
<Badge tone={services?.api_ready ? "green" : ""}>
|
||||||
{services
|
{services
|
||||||
? services.api_ready
|
? services.api_ready
|
||||||
@@ -1763,7 +1766,7 @@ function ProxyPanel({ notify }: { notify: Notify }) {
|
|||||||
: "正在查询"}
|
: "正在查询"}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
<p>查看 API、代理抓取与检测、Redis 的运行状态,管理本机服务。</p>
|
<p>查看 API、代理抓取与检测、Redis 的运行状态,管理{services?.manager === "systemd" ? "服务器" : "本机"}服务。</p>
|
||||||
{services && (
|
{services && (
|
||||||
<ul className="pool-service-list">
|
<ul className="pool-service-list">
|
||||||
{services.items.map((service) => (
|
{services.items.map((service) => (
|
||||||
@@ -2154,8 +2157,9 @@ function SettingsPanel({ notify }: { notify: Notify }) {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="info-box">
|
<div className="info-box">
|
||||||
Cookie 由当前 Windows 用户的 DPAPI
|
{auth?.browser_supported === false
|
||||||
加密,保存在项目的本地数据目录中,导出文件不包含凭据。
|
? "Cookie 加密保存在服务器的数据目录中,导出文件不包含凭据。"
|
||||||
|
: "Cookie 由当前 Windows 用户的 DPAPI 加密,保存在项目的本地数据目录中,导出文件不包含凭据。"}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ export type Proxy = {
|
|||||||
proxies: { url: string; failed: boolean; active: boolean }[];
|
proxies: { url: string; failed: boolean; active: boolean }[];
|
||||||
};
|
};
|
||||||
export type PoolServiceStatus = {
|
export type PoolServiceStatus = {
|
||||||
|
manager?: string;
|
||||||
api_ready: boolean;
|
api_ready: boolean;
|
||||||
items: {
|
items: {
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user