美文网首页golang
nginx+vue+gin配置部署

nginx+vue+gin配置部署

作者: 顶尖少爷 | 来源:发表于2024-01-19 17:35 被阅读0次

    vue打包

    npm build
    生成dist文件夹
    

    go项目打包

    go build
    

    最终项目的目录结构

    ├── dist
    │   └── 子目录文件
    ├── gin-vue-admin
    ├── config.yaml
    

    nginx配置

    server{
      listen 80;
      server_name gin.admin.com;
    
      location /{
         root /Applications/MAMP/htdocs/mygo/src/gin-vue-admin/deplay/dist;
         index index.html;
         try_files $uri $uri/ /index.html;
      }
    
     #通过路由配置进行访问goapi接口
      location /api {
         proxy_set_header Host $http_host;
         proxy_set_header X-Real-IP  $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header X-Forwarded-Proto $scheme;
         rewrite ^/api/(.*)$ /$1 break;
         proxy_pass http://127.0.0.1:8888;
      }
    
    }
    

    相关文章

      网友评论

        本文标题:nginx+vue+gin配置部署

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