commit current project
This commit is contained in:
45
nginx/conf.d/tailscale.conf
Normal file
45
nginx/conf.d/tailscale.conf
Normal file
@@ -0,0 +1,45 @@
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name tailscale.deepseak.icu;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/tailscale.deepseak.icu/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/tailscale.deepseak.icu/privkey.pem;
|
||||
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
|
||||
|
||||
client_max_body_size 5m;
|
||||
|
||||
# 匹配 /web 开头的请求
|
||||
location ^~ /web {
|
||||
proxy_pass http://localhost:3009;
|
||||
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;
|
||||
|
||||
# ... 原有跨域配置保持不变 ...
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# 匹配其他请求
|
||||
location / {
|
||||
proxy_pass http://localhost:3008;
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ events {
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
@@ -121,7 +121,7 @@ http {
|
||||
# 增加一个空的server,用于申请证书
|
||||
server {
|
||||
listen 80;
|
||||
server_name active.deepseak.icu;
|
||||
server_name aaa.deepseak.icu;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
server {
|
||||
listen 30080;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
# 代理配置
|
||||
proxy_pass http://localhost:3008;
|
||||
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;
|
||||
|
||||
# 跨域配置
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
|
||||
|
||||
# 处理 OPTIONS 请求
|
||||
if ($request_method = 'OPTIONS') {
|
||||
add_header 'Access-Control-Max-Age' 1728000;
|
||||
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
||||
add_header 'Content-Length' 0;
|
||||
return 204;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 备份并覆盖所有.conf配置文件
|
||||
for conf in *.conf; do
|
||||
cp "/etc/nginx/$conf" "/etc/nginx/${conf}.bak" 2>/dev/null || true
|
||||
cp "$conf" /etc/nginx/
|
||||
# 创建 conf.d 目录(如果不存在)
|
||||
mkdir -p /etc/nginx/conf.d
|
||||
|
||||
# 备份并覆盖 nginx.conf 文件
|
||||
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
|
||||
cp nginx.conf /etc/nginx/
|
||||
|
||||
# 备份并覆盖 conf.d 目录下的所有 .conf 文件
|
||||
for conf in conf.d/*.conf; do
|
||||
filename=$(basename "$conf")
|
||||
cp "/etc/nginx/conf.d/$filename" "/etc/nginx/conf.d/${filename}.bak" 2>/dev/null || true
|
||||
cp "$conf" /etc/nginx/conf.d/
|
||||
done
|
||||
|
||||
# 测试并重载配置
|
||||
@@ -11,8 +19,12 @@ if nginx -t; then
|
||||
systemctl reload nginx
|
||||
echo "配置已生效,HTTPS已启用"
|
||||
else
|
||||
echo "配置测试失败,正在恢复所有备份"
|
||||
for conf in *.conf; do
|
||||
mv -f "/etc/nginx/${conf}.bak" "/etc/nginx/$conf" 2>/dev/null || true
|
||||
echo "配置测试失败,已恢复备份"
|
||||
# 恢复 nginx.conf 备份
|
||||
cp /etc/nginx/nginx.conf.bak /etc/nginx/nginx.conf
|
||||
# 恢复 conf.d 目录下的所有 .conf 文件备份
|
||||
for conf in conf.d/*.conf; do
|
||||
filename=$(basename "$conf")
|
||||
mv -f "/etc/nginx/conf.d/${filename}.bak" "/etc/nginx/conf.d/$filename" 2>/dev/null || true
|
||||
done
|
||||
fi
|
||||
Reference in New Issue
Block a user