Angular 4 - Nginx / Refresh shows bad page

Viewed 2533

I have an Angular 4 application deploy on a remote server with Nginx, and accessible with this address: http://xx.xx.xx.xx/app. The app works well, I can navigate in my website but when I refresh one page, for example http://xx.xx.xx.xx/app/page1, it displays the index.html page of nginx.

Nginx's pages are located in /usr/share/nginx/html, and my app's pages are located in /var/www/app.

nginx.conf

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root /usr/share/nginx/html;
        include /etc/nginx/default.d/*.conf;                                                */

        location /app {
            root /var/www;
            try_files $uri $uri/ /index.html;
        }
    }

It seems that the line root /var/www is not taken into account during a refresh.

I heard something about a bug with try_files, and it seems that I need to add a rewrite somewhere. Thanks for help.

1 Answers
Related