0

While facing the following error below I noticed that it appears the PNG file is going through fastcgi. I'm not very familiar with nginx, but it seems wrong to me.

I did try putting some PHP code in a PNG file and it was not executed.

[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"

Is there a problem here or is it my naivety. I would have thought nginx would just send static files and not send them through anything cgi related.

Some possibly related files:

# 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;

Vhost File

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;
        }
}

If any more files are required I will add them, appreciate it!

0

If you don't have a file /mnt/web/example/public_html/images/25.png in your system, nginx will send the request for http://example.com/images/25.png to the PHP processor.

This behaviour is specified in the try_files $uri $uri/ /?$args; line.

1
  • Additionally I would recommend to add a location for pure static contents such as images (in your set-up /images/). If they are not present you can avoid hitting your PHP application stack with such requests and generating a load impact on your server. This location block can be empty or may contain an expires directive. – Jens Bradler Feb 22 '18 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.