合并 feature/domain-deploy 到 master:完成域名部署配置和 SSL 证书脚本
This commit is contained in:
+71
-34
@@ -1,84 +1,122 @@
|
||||
# Emotion Museum HTTPS Nginx 配置
|
||||
# 配置路径:/www/server/panel/vhost/nginx/emotion-museum.conf
|
||||
# 域名:lifescript.happylifeos.com
|
||||
|
||||
# HTTP 服务器 - 强制跳转 HTTPS
|
||||
server {
|
||||
listen 443 ssl;
|
||||
http2 on;
|
||||
listen 80;
|
||||
server_name lifescript.happylifeos.com;
|
||||
|
||||
# 强制跳转 HTTPS
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
||||
# HTTPS 服务器
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name lifescript.happylifeos.com;
|
||||
|
||||
# SSL 证书配置
|
||||
ssl_certificate /etc/letsencrypt/live/lifescript.happylifeos.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/lifescript.happylifeos.com/privkey.pem;
|
||||
|
||||
# SSL 优化配置
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 10m;
|
||||
|
||||
# HSTS (可选,生产环境建议开启)
|
||||
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
# ACME 挑战目录 - 用于 SSL 证书申请和续期
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
root /data/www/acme-challenge;
|
||||
allow all;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# 根路径 - 用户前端应用
|
||||
location = / {
|
||||
return 404;
|
||||
}
|
||||
|
||||
location /emotion-museum/ {
|
||||
location / {
|
||||
alias /data/www/emotion-museum/;
|
||||
autoindex off;
|
||||
# 静态资源直接返回文件,不经过 try_files
|
||||
location ~* ^/emotion-museum/(assets|static)/ {
|
||||
|
||||
# 处理 Vue Router 的 history 模式
|
||||
try_files $uri $uri/ /index.html;
|
||||
|
||||
# HTML 文件不缓存
|
||||
location ~ \.html?$ {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
add_header Pragma "no-cache";
|
||||
add_header Expires "0";
|
||||
}
|
||||
|
||||
# 静态资源缓存 1 年
|
||||
location ~ \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
expires 1y;
|
||||
try_files $uri =404;
|
||||
}
|
||||
# SPA 路由兜底
|
||||
try_files $uri $uri/ /emotion-museum/index.html;
|
||||
}
|
||||
|
||||
location = /emotion-museum {
|
||||
rewrite ^(.*)$ $1/ permanent;
|
||||
}
|
||||
|
||||
# 管理后台应用路径
|
||||
location /emotion-museum-admin/ {
|
||||
alias /data/www/emotion-museum-admin/;
|
||||
autoindex off;
|
||||
|
||||
# 处理 Vue Router 的 history 模式
|
||||
try_files $uri $uri/ /emotion-museum-admin/index.html;
|
||||
|
||||
# HTML 文件不缓存
|
||||
location ~ \.html?$ {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
add_header Pragma "no-cache";
|
||||
add_header Expires "0";
|
||||
}
|
||||
|
||||
# 静态资源缓存 1 年
|
||||
location ~ \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
expires 1y;
|
||||
}
|
||||
}
|
||||
|
||||
location = /emotion-museum-admin {
|
||||
rewrite ^(.*)$ $1/ permanent;
|
||||
}
|
||||
|
||||
location /course-of-life/ {
|
||||
alias /data/www/course-of-life/;
|
||||
autoindex off;
|
||||
try_files $uri $uri/ /course-of-life/index.html;
|
||||
}
|
||||
|
||||
location = /course-of-life {
|
||||
rewrite ^ /course-of-life/ last;
|
||||
}
|
||||
|
||||
# life-script React 应用
|
||||
# Life-Script 应用路径
|
||||
location /life-script/ {
|
||||
alias /data/www/life-script/;
|
||||
autoindex off;
|
||||
# 静态资源直接返回文件
|
||||
location ~* ^/life-script/(assets|static)/ {
|
||||
|
||||
# 处理 React Router 的 history 模式
|
||||
try_files $uri $uri/ /life-script/index.html;
|
||||
|
||||
# HTML 文件不缓存
|
||||
location ~ \.html?$ {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
add_header Pragma "no-cache";
|
||||
add_header Expires "0";
|
||||
}
|
||||
|
||||
# 静态资源缓存 1 年
|
||||
location ~ \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
expires 1y;
|
||||
try_files $uri =404;
|
||||
}
|
||||
# SPA 路由兜底
|
||||
try_files $uri $uri/ /life-script/index.html;
|
||||
}
|
||||
|
||||
location = /life-script {
|
||||
rewrite ^ /life-script/ last;
|
||||
}
|
||||
|
||||
# 后端 API 代理
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:19089;
|
||||
proxy_set_header Host $host;
|
||||
@@ -90,6 +128,7 @@ server {
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
# WebSocket 代理
|
||||
location /ws {
|
||||
proxy_pass http://127.0.0.1:19089;
|
||||
proxy_http_version 1.1;
|
||||
@@ -104,23 +143,21 @@ server {
|
||||
proxy_read_timeout 7d;
|
||||
}
|
||||
|
||||
# 健康检查端点
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
|
||||
# 隐藏文件访问控制
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
# 日志配置
|
||||
access_log /www/wwwlogs/ssl-access.log;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name lifescript.happylifeos.com;
|
||||
return 301 https://$host$request_uri;
|
||||
error_log /www/wwwlogs/ssl-error.log;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
# Emotion Museum 前端应用 Nginx 配置
|
||||
# 配置路径:/www/server/panel/vhost/nginx/emotion-museum.conf
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name lifescript.happylifeos.com;
|
||||
|
||||
# Let's Encrypt ACME 挑战位置(必须在其他 location 之前)
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
root /data/www/acme-challenge;
|
||||
allow all;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# 根路径不提供站点,避免跳转或兜底到其他 server
|
||||
location = / {
|
||||
return 404;
|
||||
}
|
||||
|
||||
# 前端应用路径
|
||||
location /emotion-museum/ {
|
||||
alias /data/www/emotion-museum/;
|
||||
|
||||
# 启用目录索引(可选)
|
||||
autoindex off;
|
||||
|
||||
# 处理 Vue Router 的 history 模式
|
||||
# 所有非文件请求都重定向到 index.html
|
||||
try_files $uri $uri/ /emotion-museum/index.html;
|
||||
|
||||
# 设置缓存策略
|
||||
# HTML 文件不缓存
|
||||
location ~ \.html?$ {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
add_header Pragma "no-cache";
|
||||
add_header Expires "0";
|
||||
}
|
||||
|
||||
# 静态资源缓存 1 年
|
||||
location ~ \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
expires 1y;
|
||||
}
|
||||
}
|
||||
|
||||
# 处理不带末尾斜杠的 /emotion-museum 请求
|
||||
location = /emotion-museum {
|
||||
rewrite ^(.*)$ $1/ permanent;
|
||||
}
|
||||
|
||||
# 管理后台应用路径
|
||||
location /emotion-museum-admin/ {
|
||||
alias /data/www/emotion-museum-admin/;
|
||||
|
||||
# 启用目录索引(可选)
|
||||
autoindex off;
|
||||
|
||||
# 处理 Vue Router 的 history 模式
|
||||
# 所有非文件请求都重定向到 index.html
|
||||
try_files $uri $uri/ /emotion-museum-admin/index.html;
|
||||
|
||||
# 设置缓存策略
|
||||
# HTML 文件不缓存
|
||||
location ~ \.html?$ {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
add_header Pragma "no-cache";
|
||||
add_header Expires "0";
|
||||
}
|
||||
|
||||
# 静态资源缓存 1 年
|
||||
location ~ \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
expires 1y;
|
||||
}
|
||||
}
|
||||
|
||||
# 处理不带末尾斜杠的 /emotion-museum-admin 请求
|
||||
location = /emotion-museum-admin {
|
||||
rewrite ^(.*)$ $1/ permanent;
|
||||
}
|
||||
|
||||
# 体验前端应用路径 (course-web)
|
||||
location /course-of-life/ {
|
||||
alias /data/www/course-of-life/;
|
||||
|
||||
# 启用目录索引(可选)
|
||||
autoindex off;
|
||||
|
||||
# 处理 SPA 的 history 模式 (React Router)
|
||||
# 所有非文件请求都重定向到 index.html
|
||||
try_files $uri $uri/ /course-of-life/index.html;
|
||||
|
||||
# 设置缓存策略
|
||||
# HTML 文件不缓存
|
||||
location ~ \.html?$ {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
add_header Pragma "no-cache";
|
||||
add_header Expires "0";
|
||||
}
|
||||
|
||||
# 静态资源缓存 1 年
|
||||
location ~ \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
expires 1y;
|
||||
}
|
||||
}
|
||||
|
||||
# 处理不带末尾斜杠的 /course-of-life 请求
|
||||
location = /course-of-life {
|
||||
# 不进行 301/302 外部跳转:内部改写到 /course-of-life/ 交给下方 SPA location 处理
|
||||
# 这样 URL 仍是 /course-of-life,但返回内容与 /course-of-life/ 完全一致(且不会触发"下载")
|
||||
rewrite ^ /course-of-life/ last;
|
||||
}
|
||||
|
||||
# 后端 API 代理
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:19089;
|
||||
proxy_set_header Host $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 $scheme;
|
||||
|
||||
# 超时设置
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
# WebSocket 代理
|
||||
location /ws {
|
||||
proxy_pass http://127.0.0.1:19089;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $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 $scheme;
|
||||
|
||||
# WebSocket 超时设置
|
||||
proxy_connect_timeout 7d;
|
||||
proxy_send_timeout 7d;
|
||||
proxy_read_timeout 7d;
|
||||
}
|
||||
|
||||
# 健康检查端点
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
|
||||
# 禁止访问敏感文件
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
access_log /www/wwwlogs/access.log;
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
# Emotion Museum HTTPS Nginx 配置
|
||||
# 配置路径:/www/server/panel/vhost/nginx/emotion-museum.conf
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
http2 on;
|
||||
server_name lifescript.happylifeos.com;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/lifescript.happylifeos.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/lifescript.happylifeos.com/privkey.pem;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 10m;
|
||||
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
root /data/www/acme-challenge;
|
||||
allow all;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location = / {
|
||||
return 404;
|
||||
}
|
||||
|
||||
location /emotion-museum/ {
|
||||
alias /data/www/emotion-museum/;
|
||||
autoindex off;
|
||||
# 静态资源直接返回文件,不经过 try_files
|
||||
location ~* ^/emotion-museum/(assets|static)/ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
expires 1y;
|
||||
try_files $uri =404;
|
||||
}
|
||||
# SPA 路由兜底
|
||||
try_files $uri $uri/ /emotion-museum/index.html;
|
||||
}
|
||||
|
||||
location = /emotion-museum {
|
||||
rewrite ^(.*)$ $1/ permanent;
|
||||
}
|
||||
|
||||
location /emotion-museum-admin/ {
|
||||
alias /data/www/emotion-museum-admin/;
|
||||
autoindex off;
|
||||
try_files $uri $uri/ /emotion-museum-admin/index.html;
|
||||
}
|
||||
|
||||
location = /emotion-museum-admin {
|
||||
rewrite ^(.*)$ $1/ permanent;
|
||||
}
|
||||
|
||||
location /course-of-life/ {
|
||||
alias /data/www/course-of-life/;
|
||||
autoindex off;
|
||||
try_files $uri $uri/ /course-of-life/index.html;
|
||||
}
|
||||
|
||||
location = /course-of-life {
|
||||
rewrite ^ /course-of-life/ last;
|
||||
}
|
||||
|
||||
# life-script React 应用
|
||||
location /life-script/ {
|
||||
alias /data/www/life-script/;
|
||||
autoindex off;
|
||||
# 静态资源直接返回文件
|
||||
location ~* ^/life-script/(assets|static)/ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
expires 1y;
|
||||
try_files $uri =404;
|
||||
}
|
||||
# SPA 路由兜底
|
||||
try_files $uri $uri/ /life-script/index.html;
|
||||
}
|
||||
|
||||
location = /life-script {
|
||||
rewrite ^ /life-script/ last;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:19089;
|
||||
proxy_set_header Host $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 $scheme;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
location /ws {
|
||||
proxy_pass http://127.0.0.1:19089;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $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 $scheme;
|
||||
proxy_connect_timeout 7d;
|
||||
proxy_send_timeout 7d;
|
||||
proxy_read_timeout 7d;
|
||||
}
|
||||
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
access_log /www/wwwlogs/ssl-access.log;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name lifescript.happylifeos.com;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
Reference in New Issue
Block a user