I'm trying to make a custom 404 error with nginx.
First in my local machine I added the following lines to the default site:
error_page 404 /custom_404.html;
location = /custom_404.html {
root /usr/share/nginx/html;
internal;
}
Then in the /usr/share/nginx/html folder I created a nes file named custom_404.html.
Then I went to my development machine and tried to do the same but with aout any luck.
One of the things that I noticed is that in local I'm using the 1.9.3 version and in the development enviroment the 1.2.1 version, and also that the html forlder (/usr/share/nginx/html) doesnt exists.
And the last thing is that in development I use nginx for django aplications so my config file it's something like this:
server {
listen 80;
server_name test.example.net;
# output compression saves bandwidth
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
client_max_body_size 10M;
if ($http_user_agent ~* '(blackberry|
iemobile|iphone|ipod|mobile|Mobile|
nokia|opera\s+mini|smartphone|symbian|webOS)') {
set $mobile on;
}
if ($http_user_agent ~* 'ipad'){
set $mobile off;
}
if ($host = example.net) {
rewrite ^(.*)$ http://www.example.net$1 permanent;
}
if ($uri = '/') {
set $home_es on;
}
if ($http_referer ~* ^http://test.example.net){
set $home_es off;
}
if ($home_es = on) {
rewrite ^(.*)$ /es$1 permanent;
}
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6].(?!.*SV1)";
# media - folder in uri for admin static files
location /newmedia/ {
expires 30d;
root /media/jumbo_project;
}
location /media/ {
expires 30d;
alias /home/jumbo/media/jumbo_project/newmedia/;
}
location /static/ {
expires 30d;
root /media/jumbo_project;
}
error_page 502 503 504 500 /50x.html;
location /50x.html {
internal;
}
location / {
proxy_pass http://localhost:8000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 60;
}
log_format log_time '$request_time $remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
access_log /var/log/nginx/jumbo-wsgi.access.log log_time;
error_log /var/log/nginx/jumbo-wsgi.error.log;
I've run out of google results to try so if someone can give me a lead to proceed it would be great.