2017-12-06 1 views
1

Ich muss die Zielseite unter / öffnen, und vueJS-Anwendung unter /app. Hier ist meine aktuelle nginx Setup:nginx + vueJS + statische Zielseite

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; 
    } 
} 

Es öffnet sich Landung auf / und vueJS app, wenn ich nach /app gehen, aber wenn ich /app/login öffnen es zu Zielseite geht statt vue Anwendung. Was mache ich falsch ?

+0

Und welche Datei sollte in diesem Fall geöffnet werden? '[..]/app/dist/index.html'? – raina77ow

+0

Ja, alles, was mit '/ app' anfängt, sollte '/ app/dist/index.html' öffnen. – Valera

+0

Probieren Sie:' alias/var/www/app/dist; 'ohne das nachfolgende'/'. –

Antwort

1

Ich habe keine Ahnung warum, aber last zu Vue-Anwendung hinzufügen Konfiguration korrigiert es. Hier ist, wie die Konfiguration jetzt aussieht:

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; 
    } 
}