Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx + vueJS + static landing page

Tags:

nginx

I need to open the landing page on /, and vueJS application on /app. Here is my current nginx setup:

server {
    listen 80;

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

    location / {
            alias /var/www/landing/dist/;
            try_files $uri $uri/ /index.html;
    }
}

It opens landing on /, and vueJS app when I go to /app, however, if I open /app/login it goes to landing page instead of vue application. What am I doing wrong ?

like image 702
Valera Avatar asked Dec 06 '17 16:12

Valera


1 Answers

I have no idea why, but adding last to vue application configuration fixed it. Here is how the config looks now:

server {
    listen 80;

    location /app {
        alias /var/www/app/dist; # removed the / at the end
        try_files $uri $uri/ /index.html last; # here is the trick
    }

    location / {
        alias /var/www/landing/dist/;
        try_files $uri $uri/ /index.html;
    }
}
like image 175
Valera Avatar answered Oct 12 '22 08:10

Valera