There is a certain directory /nginx_root_dir in which the index.html file lies. How to write a config so that all addresses domain.com , domain.com/app , domain.com/app/1 given index.html?

UPD:
Here is the file itself. In the dest folder is index.html. Why does not it work? Error 404.

 server { listen 127.0.0.1:80; server_name nodejs-server.com root /home/ivan/server/fron-end-empty/dest; log_not_found off; charset utf-8; location / { try_files index.html =404; } } 
  • error_page 404 = /index.html; - Darth

3 answers 3

I redirect this “stub” in the absence of the site:

 server { listen порт; server_name имя.сервера; error_page 404 /index.html; location / { root /каталог; index index.html; } 

}

in /каталог is the only file - /каталог /каталог/index.html with the desired message.

    For example:

     server { listen 127.0.0.1:80; server_name nodejs-server.com log_not_found off; charset utf-8; location / { alias /home/ivan/server/fron-end-empty/dest/index.html; } } 
       location / { try_files /index.html =404; } 
      • did as you said and does not work. Why? - vas
      • @shatal magic! Try a slash at the beginning to add ... - Pavel Mayorov
      • does not help .... - vas