nginx + vueJS + 静态登陆页面

标签 nginx

我需要在 / 上打开登陆页面, 和 vueJS 应用在 /app .这是我当前的 nginx 设置:

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

它打开登陆 / , 和 vueJS app 当我去 /app 时,但是,如果我打开 /app/login它转到登录页面而不是 vue 应用程序。我究竟做错了什么 ?

最佳答案

我不知道为什么,但添加 last vue 应用程序配置修复了它。这是配置现在的样子:

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

关于nginx + vueJS + 静态登陆页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47679208/

相关文章:

ssl - 使用自签名 SSL 证书

ruby-on-rails - Nginx 在大文件上传时随机失败

php 71 不创建 php7.0-fpm.sock

python - 如何围绕第三方 servlet 包装 Plone 身份验证?

amazon-web-services - Kubernetes nginx 入口代理传递给 websocket

python - 在 nginx 上为 django 项目设置 ssl

linux - 为什么 PMP(穷人的分析器)不能在 nginx 上工作?

python - ./manage.py runserver 使用 https

amazon-web-services - 在 AWS Linux 2 上运行的 NGINX 配置中访问 Elastic Beanstalk 环境属性

php - 用于 php 的内存缓存 - 无法连接