使用nginx部署后刷新页面时,Vue JS出现错误

时间:2020-04-20 13:12:23

标签: vue.js nginx

嗨,我已经尝试了很多事情,文档说我必须通过在conf文件中设置try_files $uri $uri/ /index.html;来重写路径,但是问题是我的路径不一样,而且我不知道如何显示当前路径

我认为我的问题是添加了错误的路径,我在像这样检查nginx日志后遇到错误

     6#6: *1 rewrite or internal redirection cycle while internally redirecting to "/home/project/projectName/app/admin/src/router/index.js",

这是我在服务器中的index.js文件

/home/project/projectName/app/admin/src/router/index.js

在我的conf中,我已经传递了类似的内容

upstream admin-cluster {
  least_conn;
  server admin:3000 weight=10 max_fails=3 fail_timeout=30s;
  # server localhost:3000 weight=10 max_fails=3 fail_timeout=30s;
}

server {
        listen 80;
        server_name test.example.com;

  location / {
    sendfile off;
    try_files $uri $uri/ /home/project/projectName/app/admin/src/router/index.js; 
    proxy_pass         http://admin-cluster;
    proxy_redirect     default;
    proxy_http_version 1.1;

    proxy_set_header   Host              $host;
    proxy_set_header   X-Real-IP         $remote_addr;
    proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_max_temp_file_size 0;

    #this is the maximum upload size
    client_max_body_size       10m;
    client_body_buffer_size    128k;

    proxy_connect_timeout      90;
    proxy_send_timeout         90;
    proxy_read_timeout         90;
    proxy_buffering            off;
    proxy_request_buffering    off; # Required for HTTP CLI commands in Jenkins > 2.54
    proxy_set_header Connection ""; # Clear for keepalive
  }
}

如何检查try_files中的当前路径

我可以检查一些想法,例如使用pwd命令

0 个答案:

没有答案