I'm trying to get a custom 404 page to show up on a specific server. The 404 error page is located at /www/example/html/404.php and the website root is /www/example/html/
Currently, any non-existant page yields this result https://i.sstatic.net/4ojd5.png, and does not seem to be loading my custom 404 page (which has some custom styles and menus). I've been struggling with this for a few days now with different .conf settings, my current nginx.conf is below. I am on Ubuntu 12, Nginx 1.1.19 and using php-fpm.
user www-data;
worker_processes 5;
error_log logs/error.log;
worker_rlimit_nofile 8192;
events {
worker_connections 4096;
}
http {
include mime.types;
include fastcgi_params;
index index.php index.html index.htm;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
server_names_hash_bucket_size 128;
server {
listen 80;
server_name example.com;
client_max_body_size 20M;
root /www/example/html;
access_log logs/example.access.log;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/(.*)$ /index.php?q=$1;
}
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
location /404.php {
internal;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
error_page 404 /404.php;
fastcgi_pass 127.0.0.1:9000;
}
location ~ /\.ht {
deny all;
}
}