nginx - PNG 檔案透過 fastcgi?

nginx - PNG 檔案透過 fastcgi?

當遇到下面的錯誤時,我注意到 PNG 檔案似乎正在通過 fastcgi。我對nginx不是很熟悉,但對我來說似乎是錯的。

我確實嘗試將一些 PHP 程式碼放入 PNG 檔案中,但它沒有被執行。

[warn] 2507#0: *35744 an upstream response is buffered to a temporary file /www/wdlinux/nginx-1.8.1/fastcgi_temp/9/60/0000012609 while reading upstream, client: 888.888.888.888, server: example.com, request: "GET /images/25.png HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-55-cgi.sock:", host: "example.com", referrer: "http://example.com/app.php"

是這裡有問題還是我太天真了。我以為 nginx 只會發送靜態文件,而不是透過任何與 cgi 相關的東西發送它們。

一些可能相關的文件:

# nginx conf conf/nginx.conf
# Created by http://www.wdlinux.cn
# Last Updated 2010.06.01
user  www www;
worker_processes  3;
error_log  logs/error.log  notice;
pid        logs/nginx.pid;
worker_rlimit_nofile 5120;
events {
    use epoll;
    worker_connections  5120;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    server_names_hash_bucket_size 128;
    client_header_buffer_size 256k;
    large_client_header_buffers 8 64k;
    client_max_body_size 100m;
    limit_conn_zone $binary_remote_addr zone=one:32k;

    sendfile        on;
    tcp_nopush     on;

    keepalive_timeout  60;
    tcp_nodelay on;

    gzip  on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types       text/plain application/x-javascript text/css application/xml;
    gzip_vary on;

    log_format  wwwlogs  '$remote_addr - $remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for';
    #include default.conf;
    include vhost/*.conf;
}

naproxy.conf

proxy_connect_timeout 30s;
proxy_send_timeout   90;
proxy_read_timeout   90;
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   $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;

虛擬主機文件

server {
        listen       80;
        root /mnt/web/example/public_html;
        server_name example.com example.com;
        index  index.html index.php index.htm;
        error_page  400 /errpage/400.html;
        error_page  403 /errpage/403.html;
        error_page  404 /errpage/404.html;
        error_page  503 /errpage/503.html;
        location ~ \.php(.*)$ {
                fastcgi_pass  unix:/tmp/php-55-cgi.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $DOCUMENT_ROOT$fastcgi_script_name;
                fastcgi_param PATH_INFO $2;
                include fcgi.conf;
        }
        location ~ /\.ht {
                deny  all;
        }
        location / {
                 try_files $uri $uri/ /?$args;
        }
}

如果需要更多文件,我會添加它們,不勝感激!

答案1

如果您的系統中沒有文件/mnt/web/example/public_html/images/25.png,nginx 會將請求傳送http://example.com/images/25.png到 PHP 處理器。

此行為在該行中指定try_files $uri $uri/ /?$args;

相關內容