「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 {
        }
    }

版权声明:本文为ftrako原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/ftrako/p/10234268.html