Nginx文件已经存在全局反向代理问题排查记录

项目应用场景

伪静态错误图

1.png

我们可以看到,伪静态文件已经存在全局反向代理,产生报错的原因是因为nginx配置文件里面一个网站只能包含一个location ,nginx.conf的相关配置出现了问题

nginx.conf配置出错的解决方法

第一步


查看网站的相关配置文件

1.png

server
{ listen 80; 
server_name www.123456.com; 
index index.php index.html index.htm default.php default.htm default.html; 
root /www/wwwroot/www.123456.com;
write/www.123456.com.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 
{
 expires 30d; error_log /dev/null; access_log /dev/null; 
 }
location ~ .*\.(js|css)?$ 
{ 
expires 12h; error_log /dev/null; access_log /dev/null; 
} 
access_log /www/wwwlogs/www.123456.com.log; error_log /www/wwwlogs/www.123456.com.error.log; 
}

第二步

查看规则配置文件

1.png

可以看到这个文件没有任何配置,我们可以确定这个网站的配置,没有伪静态配置

接着查看nginx文件的配置,这个可以直接点进去配置,也可以直接通过ssh软件登录然后直接修改文件

查看这个nginx.conf配置文件

user www www;
worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
#include luawaf.conf;
include proxy.conf;
default_type application/octet-stream;
server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript 
text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
server_tokens off;
access_log off;
server
{
listen 888;
server_name phpmyadmin;
index index.html index.htm index.php;
root /www/server/phpmyadmin;
location ~ /tmp/ {
return 403;
}
#error_page 404 /404.html;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
access_log /www/wwwlogs/access.log;
}
include /www/server/panel/vhost/nginx/*.conf;
}

 然后,我们先删除location /匹配规则,再去添加反向代理,就能添加成功了

原创文章,作者:网友投稿,如若转载,请注明出处:https://www.cloudads.cn/archives/4148.html

发表评论

登录后才能评论