programing

nginx가 있는 vue: 경로가 일치하지 않습니다.

prostudy 2022. 7. 27. 21:41
반응형

nginx가 있는 vue: 경로가 일치하지 않습니다.

nginx(1.10.2)를 사용하여 vue(2.1.x)를 셋업하고 있습니다.설정은 다음과 같습니다.

location / {
    root   /var/lib/myRepo/dist/;
    index  index.html;
}

기능은 'http://localhost:8080/'을 누르면 작동하지만 'http://localhost:8080/products/home'과 같은 다른 URL을 누르면 다음과 같이 표시됩니다.

404 찾을 수 없음

또, 다음과 같이 시도했습니다.

root   /var/lib/myRepo/dist/;
location / {
   try_files $uri $uri/ index.html$query_string;
}

여기서 문제가 될 수 있는 부분과 이를 수정하는 방법.

다음과 같이 할 수 있습니다.

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        try_files $uri $uri/ @router;
        index index.html;
    }

    location @router {
        rewrite ^.*$ /index.html last;
    }
}

언급URL : https://stackoverflow.com/questions/41392508/vue-with-nginx-path-not-matching

반응형