上传文件至 /

This commit is contained in:
chunzhi 2025-03-27 10:34:02 -04:00
parent 8388a82753
commit aa779cd7ea

View File

@ -224,25 +224,15 @@ EOF
# 配置Nginx # 配置Nginx
echo -e "${BLUE}配置Nginx...${PLAIN}" echo -e "${BLUE}配置Nginx...${PLAIN}"
# 检查Nginx配置目录结构 # 创建网站目录
if [ -d /etc/nginx/sites-available ]; then mkdir -p /var/www/${domain}/html
# Debian/Ubuntu风格的配置
echo -e "${BLUE}检测到Debian/Ubuntu风格的Nginx配置${PLAIN}"
# 删除默认配置 # 设置目录权限
if [ -f /etc/nginx/sites-enabled/default ]; then chown -R $USER:$USER /var/www/${domain}/html
rm -f /etc/nginx/sites-enabled/default chmod -R 755 /var/www/${domain}
fi
# 创建网站目录 # 创建示例页面
mkdir -p /var/www/${domain}/html cat > /var/www/${domain}/html/index.html << EOF
# 设置目录权限
chown -R $USER:$USER /var/www/${domain}/html
chmod -R 755 /var/www/${domain}
# 创建示例页面
cat > /var/www/${domain}/html/index.html << EOF
<html> <html>
<head> <head>
<title>Welcome</title> <title>Welcome</title>
@ -254,8 +244,11 @@ EOF
</html> </html>
EOF EOF
# 创建Nginx配置文件 # 创建Nginx配置目录如果不存在
cat > /etc/nginx/sites-available/${domain} << EOF mkdir -p /etc/nginx/conf.d
# 创建Nginx配置文件
cat > /etc/nginx/conf.d/${domain}.conf << EOF
server { server {
listen 80; listen 80;
listen [::]:80; listen [::]:80;
@ -304,84 +297,6 @@ server {
} }
EOF EOF
# 创建符号链接启用配置
ln -s /etc/nginx/sites-available/${domain} /etc/nginx/sites-enabled/
else
# CentOS/其他风格的配置
echo -e "${BLUE}检测到CentOS/其他风格的Nginx配置${PLAIN}"
# 创建网站目录
mkdir -p /var/www/${domain}/html
# 设置目录权限
chown -R $USER:$USER /var/www/${domain}/html
chmod -R 755 /var/www/${domain}
# 创建示例页面
cat > /var/www/${domain}/html/index.html << EOF
<html>
<head>
<title>Welcome</title>
</head>
<body>
<h1>Success! Your Nginx server is successfully configured. </h1>
<p>This is a sample page.</p>
</body>
</html>
EOF
# 创建Nginx配置文件
cat > /etc/nginx/conf.d/${domain}.conf << EOF
server {
listen 80;
listen [::]:80;
server_name ${domain} www.${domain};
return 301 https://\$host\$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/ssl/cert.pem;
ssl_certificate_key /etc/ssl/key.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
# intermediate configuration
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:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
# HSTS (ngx_http_headers_module is required) (63072000 seconds)
add_header Strict-Transport-Security "max-age=63072000" always;
server_name ${domain} www.${domain};
root /var/www/${domain}/html;
index index.html index.htm index.nginx-debian.html;
location / {
try_files \$uri \$uri/ =404;
}
location /ray {
if (\$http_upgrade != "websocket") {
return 404;
}
proxy_redirect off;
proxy_pass http://127.0.0.1:10000;
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;
}
}
EOF
fi
# 调整nginx.conf # 调整nginx.conf
if grep -q "server_names_hash_bucket_size" /etc/nginx/nginx.conf; then if grep -q "server_names_hash_bucket_size" /etc/nginx/nginx.conf; then
sed -i 's/#server_names_hash_bucket_size 64;/server_names_hash_bucket_size 64;/g' /etc/nginx/nginx.conf sed -i 's/#server_names_hash_bucket_size 64;/server_names_hash_bucket_size 64;/g' /etc/nginx/nginx.conf
@ -539,8 +454,7 @@ uninstall_v2ray() {
apt remove -y nginx apt remove -y nginx
fi fi
rm -rf /etc/nginx/sites-available rm -rf /etc/nginx/conf.d
rm -rf /etc/nginx/sites-enabled
rm -rf /var/www rm -rf /var/www
echo -e "${GREEN}Nginx已卸载${PLAIN}" echo -e "${GREEN}Nginx已卸载${PLAIN}"
@ -553,7 +467,7 @@ view_v2ray_config() {
cat /usr/local/etc/v2ray/config.json cat /usr/local/etc/v2ray/config.json
echo -e "\n${BLUE}Nginx配置信息${PLAIN}" echo -e "\n${BLUE}Nginx配置信息${PLAIN}"
ls -l /etc/nginx/sites-enabled/ ls -l /etc/nginx/conf.d/
echo -e "\n${BLUE}V2Ray运行状态${PLAIN}" echo -e "\n${BLUE}V2Ray运行状态${PLAIN}"
systemctl status v2ray systemctl status v2ray