我的知识记录

NginxNginx多域名_安全加固

Nginx多域名时分清是Web服务器本身问题还是后端问题。Nginx 502是后端(PHP-FPM/应用)没响应,504是后端超时,403是Nginx权限或deny规则,404是root路径或伪静态。错误码已经告诉你方向。

反向代理配置:Nginx location / { proxy_pass http://后端IP:端口; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }。后端没启动或端口不通会502,后端处理慢会504。proxy_read_timeout增大超时。

参考(Nginx配置与排查): ``` # 语法检测与重载 nginx -t nginx -s reload # 或 systemctl reload nginx

# 服务状态 systemctl status nginx systemctl restart nginx

# 错误日志 tail -50 /var/log/nginx/error.log tail -100 /www/wwwlogs/错误日志.log

# 端口监听 netstat -tlnp | grep nginx ss -tlnp | grep :80

# Nginx站点配置示例 server { listen 80; server_name 域名; root /www/wwwroot/域名; index index.html index.php;

# 伪静态 location / { try_files $uri $uri/ /index.php?$query_string; }

# PHP location ~ .php$ { fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; }

# 上传大小 client_max_body_size 100m;

# 禁止敏感文件 location ~* .(sql|bak|log|sh)$ { deny all; } } ```

伪静态规则错是Nginx多域名的常见原因。配置语法错看nginx -t报错行修正;端口被占用改listen端口或停占用进程;进程未启动systemctl start;权限不足chown/chmod;模块缺失安装对应模块;代理后端未响应启动后端服务;上传大小超限改client_max_body_size;超时太短改proxy_read_timeout/fastcgi_read_timeout;location匹配错误调整匹配顺序。

Apache .htaccess不生效:检查httpd.conf里Directory段的AllowOverride是否All(None时 .htaccess完全忽略)、mod_rewrite是否开启(httpd -M | grep rewrite)、.htaccess文件权限644、路径是否在网站根目录。虚拟主机用户在面板开启"伪静态"。

NginxNginx多域名_安全加固

标签:

更新时间:2026-09-03 16:53:44

上一篇:FTP大文件上传服务端配置优化指南_FTP大文件上传连接重置教程详解

下一篇:微信PC版多开方法bat_详细操作教程_封号风险说明