I have a Gatsby site set up with nginx. I know that Gatsby uses whatever component that exists in the pages/404.js
as the 404 page. If I navigate to www.mysite.com/404 I can see the custom Gatsby 404 page I created, however this is the only time I see the Gatsby 404 component. If I navigate to www.mysite.com/blahblahblah or any other non-existent page I see the default white nginx 404 page.
I'm familiar with Gatsby but a noob when it comes to nginx. How can I set up my nginx config to redirect my users to my custom Gatsby 404 component when the user navigates to a non-existent page instead of showing the default nginx 404 page?
Here is my nginx config:
server {
listen 80;
sendfile on;
default_type application/octet-stream;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ /index.html =404;
}
}