上传文件至 /
This commit is contained in:
parent
8388a82753
commit
aa779cd7ea
@ -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}"
|
# 设置目录权限
|
||||||
|
chown -R $USER:$USER /var/www/${domain}/html
|
||||||
# 删除默认配置
|
chmod -R 755 /var/www/${domain}
|
||||||
if [ -f /etc/nginx/sites-enabled/default ]; then
|
|
||||||
rm -f /etc/nginx/sites-enabled/default
|
# 创建示例页面
|
||||||
fi
|
cat > /var/www/${domain}/html/index.html << EOF
|
||||||
|
|
||||||
# 创建网站目录
|
|
||||||
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>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Welcome</title>
|
<title>Welcome</title>
|
||||||
@ -253,9 +243,12 @@ EOF
|
|||||||
</body>
|
</body>
|
||||||
</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;
|
||||||
@ -303,84 +296,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
|
||||||
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user