「ng」生产版本部署,404 Not Found问题

【问题】

使用nginx服务,使用 ng build --prod 后生成dist目录,在nginx.conf配置中指向dist后发现除了首页正常,其他都是404 Not Found

 

【解决】

其实官网已有解答,增加映射即可,参考我的nginx.conf的配置文件

server {
        listen       80;
        server_name  127.0.0.1;
        location / {
            root         /home/workspace/mysite/mysite-ui/dist/mysite-ui;
            try_files $uri $uri/ /index.html;
        }

        # Load configuration files for the default server block.
        #include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

posted on 2019-01-07 17:01  trako  阅读(243)  评论(0编辑  收藏  举报

导航