我刚刚遇到了一个非常奇怪的问题。我在我的网站和 svg 中使用的一些字体没有加载,而昨天一切正常。我最近所做的唯一更改是一些重写以删除扩展名。
每个路径都是正确的,并且主nginx.conf
文件包含include /etc/nginx/mime.types;
再次,昨天一切正常。
这是我的配置文件,这是我唯一更改的内容。
server {
listen 80;
listen [::]:80;
server_name mysite.app;
rewrite ^(/.*)\.html(\?.*)?$ $1$2 permanent;
rewrite ^/(.*)/$ /$1 permanent;
root /var/www/html/;
index index.php index.html index.htm index.nginx-debian.html;
location / {
#try_files $uri $uri.html $uri/ @extensionless-php;
try_files $uri/index.html $uri.html $uri/ @extensionless-php;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
location ~* \.(pdf)$ {
expires 30d;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
if ($request_uri ~ ^/([^?]*)\.php$) {
return 307 /$1;
}
if ($request_uri ~ ^/([^?]*)\.php(\?+)) {
return 302 /$1?$args;
}
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
location ~ /\.ht {
deny all;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mysite.app/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mysite.app/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
listen 443 ssl http2; # managed by Certbot
server_name www.mysite.app;
ssl_certificate /etc/letsencrypt/live/mysite.app/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mysite.app/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
return 301 https://mysite.app$request_uri;
}
server {
if ($host = www.mysite.app) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name www.mysite.app;
return 404; # managed by Certbot
}
运行curl -IL <resource_location>
时出现HTTP/1.1 404 Not Found
错误。
查看此处的注释行:
您还
$uri
从 try_files 语句中删除了该术语。该术语负责提供与文件名直接匹配的任何 URI。您应该恢复它,例如:
有关详细信息,请参阅此文档。