美文网首页Nginx高端成长之路Go
解决:Go Web项目中前端部署Nginx时,Vue发布的静态页

解决:Go Web项目中前端部署Nginx时,Vue发布的静态页

作者: 承诺一时的华丽 | 来源:发表于2019-08-06 00:19 被阅读5次
    重点在于:try_files $uri $uri/ /index.html;
    server {
            listen       7000;  
            server_name  127.0.0.1 localhost;
    
            proxy_set_header   Host            $host;
            proxy_set_header   Remote_Addr     $remote_addr;
            proxy_set_header   X-Real-IP       $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size    100m;
                    
            # VUE 发布的静态文件
            location / {
              root   C:\website\zm_new\page\wdjl\manage;
              index   index.html;
              try_files $uri    $uri/   /index.html;  #重点解决刷新空白或找不到页面
            }           
     
            # Api服务
            location /api/ {
              proxy_pass                http://127.0.0.1:8055/api/;
            }
            
            #普通静态文件夹
            location /wdjl/web/ {
              root   C:\website\zm_new\page;
              index   index.html;
            } 
            
            # 文件服务
            location /files/ {
              proxy_pass                http://127.0.0.1:8055/files/;
            } 
            
            error_page   404 500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }
    
    • 已实战验证

    相关文章

      网友评论

        本文标题:解决:Go Web项目中前端部署Nginx时,Vue发布的静态页

        本文链接:https://www.haomeiwen.com/subject/ezrbdctx.html