Custom 404 error page in nginx

preview_player
Показать описание
Custom error page in nginx

1. /usr/share/nginx/html
3. Add content of your html file
4. sudo vim /etc/nginx/sites-enabled/default
5. add error handling code:

root /usr/share/nginx/html;
internal;
}

7. nginx -t
8. sudo service nginx restart

Voilà ! xx
Комментарии
Автор

The reason i love this tutorial is because it is super simple, short and to the point. I already have a fair idea about how the system works and i just wanted a concise guide as to set my custom pages. Keep up the videos.

nove
Автор

She is Kim of technical world, where delivery matters more than content 😂

kushg
Автор

Thanks for it Very helpful! Please making more videos on nginx optimization.

chetansogra
Автор

Awesome presentation. Thank you, this is great. one thing though ... site-enabled directory is not present on my default install in ubuntu 20 (from AWS). Do I have to create it or symlink it? Most nginx presentations mention "site-enabled", they all assume everyone has that same config. If you can create a video how to configure from a scratch install it would help tremendously

chuckohana
Автор

i never knew i was so much into Nginx until i saw this video :p .

shahezad
Автор

just so everyone knows if you simply want to redirect the user to the 404 page whenever a non-existent route is trying to be accessed, you just update the fallback html file in:

location / {
(i.e) index.html
#this is the important line
try_files $uri $uri/ /404.html
}

just make sure your 404 html file is in the same location as the rest of your pages/html files. Nginx does not by default throw a 404 if a route that is not defined is entered in the address bar.

DEBO
Автор

Why not use: 'nginx -s reload' to read the new config in nginx?

Other than that: very nice job!

flexairz
Автор

hey I got 404 not found on my website. Till yesterday it was working fine. It is hosted on nginx. Please help me

rk-
Автор

Hi, nice tutorial. Thumbs up :)

I'm using a nginx docker image for a small setup and this image is missing the sites-enabled folder and the default file.
I've went on to create the default file as shown in your tutorials and other on the internet but in docker I can't really restart the service.

I've tried docker restart CONTAINER_ID - did not work.
I've tried /usr/sbin/nginx -s reload from inside the container - did not work.

I'm using the nginx:1.12.0-alpine docker images.
Cheers!

danielwi
Автор

Thank you very much, I was stuck with this

I speak english very bad, i need tranlator google :D

emcema