• Tried the rules you have in FAQ, but didn’t succeed. Is there a proper way to debug the problem? Firstly it is not working. Secondly, if it would – I still don’t want to pass every request through the script, instead would be great to serve a file if it exists. Here is my .conf

    can it be related to the line where I forbid external requests to all .php?

    server {
    	#server name
        server_name example.com www.example.com;
    	
        #local connection
        listen 127.0.0.1:81;
    
        #root
        root /var/www/example.com;
        index index.php;
    
    	#gzip the text
        gzip                on;
        gzip_comp_level     9;
        gzip_min_length     512;
        gzip_buffers        8 64k;
        gzip_types text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
        gzip_proxied        any;
    
        #forbid hidden files
        location ~ /\. {
            deny all;
        }
    
        #forbid scripts requests
        location ~* /(?:uploads|files)/.*\.php$ {
            deny all;
        }
    	#serve webp
    	if ($http_accept ~* “webp”){
    	add_header Vary Accept;
    	rewrite ^/(.*).(jpe?g)$ /wp-content/plugins/webp-express/wod/webp-on-demand.php?source=$document_root$request_uri&wp-content=wp-content&%1 break;
    	}
    
        #search for file
        location / {
         try_files $uri $uri/ /index.php?q=$uri&$args;
        }
    	
        #slash for wp-admin
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    	
        location ~ \.php$ {
            #send to fpm
    		try_files $fastcgi_script_name =404;
    		
    		fastcgi_keep_conn on;
    		include /etc/nginx/fastcgi_params;
            fastcgi_read_timeout            3600s;
            fastcgi_buffer_size             128k;
            fastcgi_buffers                 4 128k;
    		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    		fastcgi_pass unix:/run/php/php7.1-fpm.sock;
    		fastcgi_index index.php;
        }
     
    }
  • The topic ‘Also a problem on Nginx’ is closed to new replies.