我最近将我的 CentOS 7 机器从 Apache 移到了 nginx,我仍在解决这些差异。我只注意到我的一个服务器块的一个问题是访问和错误日志文件实际上没有被记录到,这使得很难解决潜在的问题。
我网站的服务器块如下所示:
server {
listen 80;
server_name example.com;
root /var/www/example.com/public_html;
index index.php;
access_log /var/www/example.com/logs/example.com_access.log;
error_log /var/www/example.com/logs/example.com_error.log error;
location / {
index index.php index.html;
}
location /reports {
autoindex on;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 404 /var/www/html/404.html;
error_page 500 502 503 504 /var/www/html/50x.html;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location /robots.txt {
#access_log off;
#log_not_found off;
}
location ~ /\.ht …
Run Code Online (Sandbox Code Playgroud) 我最近将 CentOS 7 机器上的 Web 服务器从 Apache 切换到 nginx。我使用软件在我的电脑上截取屏幕截图并将它们上传到服务器以供公众查看。最初,它在 Apache 上运行良好 - 但是,现在我遇到了一个问题,即 nginx 将为 Web 服务器上的某些 .png 图像提供 404 错误。
我用一个非常相似的问题提到了这个问题,但在我自己的问题的背景下,我无法理解解决方案。
我有下面图像服务器的服务器块的片段。
server {
listen 80;
server_name imageserver.example.com;
root /usr/share/nginx/imageserver.example.com/public_html;
access_log imageserver.example.com/logs/imageserver.example.com_access.log;
error_log imageserver.example.com/logs/imageserver.example.com_error.log crit;
location / {
index index.html index.htm;
}
location ~* \.png {
root imageserver.example.com/public_html/u/;
expires max;
add_header Pragma public;
add_header Cache-control "public, must revalidate, proxy-revalidate";
}
}
Run Code Online (Sandbox Code Playgroud)
示例链接是此图像。我已确认该文件存在于服务器上,并且具有以下权限。
$ lsa 7b724394b851299c68b15f1172f158c6.png
-rw-rw-r--. 1 jflory nginx 2.4K Nov 3 11:13 7b724394b851299c68b15f1172f158c6.png
我对如何解决这个问题感到非常困惑。可能是什么问题?