v2
This commit is contained in:
27
nginx/tailscale.conf
Normal file
27
nginx/tailscale.conf
Normal file
@@ -0,0 +1,27 @@
|
||||
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,14 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 备份并覆盖配置文件
|
||||
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
|
||||
cp nginx.conf /etc/nginx/
|
||||
# 备份并覆盖所有.conf配置文件
|
||||
for conf in *.conf; do
|
||||
cp "/etc/nginx/$conf" "/etc/nginx/${conf}.bak" 2>/dev/null || true
|
||||
cp "$conf" /etc/nginx/
|
||||
done
|
||||
|
||||
# 测试并重载配置
|
||||
if nginx -t; then
|
||||
systemctl reload nginx
|
||||
echo "配置已生效,HTTPS已启用"
|
||||
else
|
||||
echo "配置测试失败,已恢复备份"
|
||||
cp /etc/nginx/nginx.conf.bak /etc/nginx/nginx.conf
|
||||
fi
|
||||
echo "配置测试失败,正在恢复所有备份"
|
||||
for conf in *.conf; do
|
||||
mv -f "/etc/nginx/${conf}.bak" "/etc/nginx/$conf" 2>/dev/null || true
|
||||
done
|
||||
fi
|
||||
Reference in New Issue
Block a user