0

I'm in the process of setting up a subdomain with wordpress on it. I'm getting a 404 error with my nginx configuration. Currently using PHP Version: 7.0.22, not getting any errors in the php logs, but I am in nginx

/var/log/nginx/error.log

 *1 open() "/usr/share/nginx/html/50x.html" failed (2: No such file or directory), client: xxx.xxx.xxx.xxx, server: kb.workspire.io, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7-fpm.sock", host: "kb.workspire.io"

Here is my current server block

/etc/nginx/sites-available/kb.workspire.io

server {
    listen 80
    server_name kb.workspire.io;
    root /var/www/kb.workspire.io/wordpress;
    index index.php;

    location / {
            #try_files $uri $uri/ =404;
             try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    listen 443 ssl;

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /usr/share/nginx/html;
    }

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php7-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }
KingPen2
  • 3
  • 2

1 Answers1

0

The location block here:

location = /50x.html {
        root /usr/share/nginx/html;
}

is telling nginx to fetch a custom error page /usr/share/nginx/html/50x.html which is then throwing an error because it doesn't exist.

If you are using custom error pages, you'll want to fix your paths so they can be found. It certainly looks odd that the 50x.html page is expected to be in /usr/share/nginx/html but the 40x.html page is looking in /var/www/kb.workspire.io/wordpress.

If you are not using custom error pages, you can remove the error_page directives and the location = /50x.html block.

virullius
  • 1,048
  • 1
  • 9
  • 23
  • I used a server block config from another site I had and looking at it now, I believe it was the location block. It's working now, thank you – KingPen2 Sep 21 '17 at 12:32
  • Glad to hear it's working. If my answer helped you, I'd appreciate it if you could mark it as accepted. – virullius Sep 21 '17 at 13:42