记录一次css、js、images静态资源404错误

日期:2019-02-19 浏览:506次

网站误删除了nginx的.conf文件,重写进行补写,发现网站样式和图片丢失(打开报错404 not fund/nginx)。

检查了反向代理没有问题,apache的conf配置没有问题,最后发现文件路径 root 的www.liusongs.com写错为www.lius0ongs.com。造成网站静态资源加载不了。

nginx的配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
server
{
listen 80;
#listen [::]:80;
server_name www.liusongs.com liusongs.com;
index index.html index.htm index.php default.html default.htm default.php;
root /你的绝对路径/www.liusongs.com;

#error_page 404 /404.html;

# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

location /
{
try_files $uri @apache;
}

location @apache
{
internal;
proxy_pass http://127.0.0.1:88;
include proxy.conf;
}

location ~ [^/]\.php(/|$)
{
proxy_pass http://127.0.0.1:88;
include proxy.conf;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

location ~ /.well-known {
allow all;
}

location ~ /\.
{
deny all;
}

access_log /你的日志路径/y.log;
}

proxy.conf文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
proxy_connect_timeout 300s;
proxy_send_timeout 900;
proxy_read_timeout 900;
proxy_buffer_size 32k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_redirect off;
proxy_hide_header Vary;
proxy_set_header Accept-Encoding '';
proxy_set_header Host $http_host;
proxy_set_header Referer $http_referer;
proxy_set_header Cookie $http_cookie;
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;

apache的.conf文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<VirtualHost *:88>
ServerAdmin 1078050681@qq.com
php_admin_value open_basedir "/你的绝对路径/www.liusongs.com:/tmp/:/var/tmp/:/proc/"
DocumentRoot "/你的绝对路径/www.liusongs.com"
ServerName www.liusongs.com
ServerAlias liusongs.com
ErrorLog "/你的日志路径/y-error_log"
CustomLog "/你的日志路径/y-access_log" combined
<Directory "/你的绝对路径/www.liusongs.com">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
</Directory>
</VirtualHost>

没有评论

发表评论