vue 打包上线后nginx 如何配置

2019-08-27  本文已影响0人  JackLin_WEB

server {

        listen      80;

        server_name  域名;

        root  打包防止的路径;

        location / {

            try_files $uri $uri/ @router;

            index  index.html;

        }

        location @router{

            rewrite ^.*$ /index.html last;

        }

        error_page  500 502 503 504  /50x.html;

        location = /50x.html {

            root  html;

        }

    }

server {

        listen  443;

        server_name 域名;

        ssl on;

        ssl_certificate  证书路径;

        ssl_certificate_key  证书路径;

        ssl_session_timeout 5m;

        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

        ssl_prefer_server_ciphers on;

        root  前端打包路径;

        location / {

            try_files $uri $uri/ @router;

            index  index.html;

        }

        location @router{

            rewrite ^.*$ /index.html last;

        }

        error_page  500 502 503 504  /50x.html;

        location = /50x.html {

            root  html;

        }

}

1、确保vue打包路径正确

2、将前端域名部署为后端提供的域名

上一篇 下一篇

猜你喜欢

热点阅读