nginx 简单配置vue 后台server

worker_processes  1;
#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;

    #html文件
    server {
        listen       1000;
        server_name  127.0.0.1 localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   D:/work/web/dist;#文件路径
            index  index.html;#默认打开的文件
            #此为关键 , vue router mode此时可设置为`history`
            #参考https://router.vuejs.org/zh-cn/essentials/history-mode.html
            try_files $uri $uri/ /index.html;#匹配所有路径  
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容