nginx 简单配置vue 后台server

2017-12-19  本文已影响973人  wwmin_
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;
        }
    }
}
上一篇下一篇

猜你喜欢

热点阅读