• I’ve moved to Nginx (From Apache), everything works apart from 2 issues:

    /?s=searchTerm– didn’t work, had to write a rewrite rule to /search/searchTerm.

    /wp-admin just shows a 504 gateway error – in the logs it says Upstream timeout, so I’m assuming it can’t find the files correctly.

    It’s setup as advised (and now with caching), I’m unable to find anything wrong with it..

    nginx.conf below:

    fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=MYAPP:100m inactive=60m;
    fastcgi_cache_key "$scheme$request_method$host$request_uri";
    
    server {
    	listen 82 default_server;
    	listen [::]:82 default_server ipv6only=on;
    
    	root /mnt/wpmount/nen;
    	index index.php index.html index.htm;
    
    	# Make site accessible from http://localhost/
    	server_name localhost;
    
    	location / {
    
    		if ($args ~* "^s=(.*)$")
    		{
    			return 301 /search/$1;
    		}
    		#try_files $uri $uri/ /index.php?q=$uri&$args;
    		try_files $uri $uri/ /index.php?$args;
    	}
    
            location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
              expires 1M;
              access_log off;
              add_header Cache-Control "public";
            }
    
    	location ~* /(?:uploads|files)/.*\.php$ {
        		deny all;
    	}
    
    	location ~* \.(pl|cgi|py|sh|lua)\$ {
            	return 444;
    	}
    
    	# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    	#
    	location ~ \.php$ {
    		try_files $uri =404;
    		fastcgi_split_path_info ^(.+\.php)(/.+)$;
    		fastcgi_pass unix:/var/run/php5-fpm.sock;
    		fastcgi_index index.php;
    		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    		include fastcgi_params;
    
    		fastcgi_cache MYAPP;
    		fastcgi_cache_valid 200 60m;
    
    		fastcgi_cache_bypass $no_cache;
    		fastcgi_no_cache $no_cache;
    		add_header X-Cache $upstream_cache_status;
    	}
    
    	location ~ /\.ht {
    		deny all;
    	}
    
    #Cache everything by default
    set $no_cache 0;
    
    #Don't cache POST requests
    if ($request_method = POST)
    {
        set $no_cache 1;
    }
    
    #Don't cache if the URL contains a query string
    if ($query_string != "")
    {
        set $no_cache 1;
    }
    
    #Don't cache if there is a cookie called PHPSESSID
    	if ($http_cookie = "PHPSESSID")
    	{
        	set $no_cache 1;
    	}
    }
Viewing 1 replies (of 1 total)
  • try to add the following line under the server_name line.

    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
Viewing 1 replies (of 1 total)
  • The topic ‘Nginx – WP-Admin shows 504 Gateway errro’ is closed to new replies.