node+express+MySQL+Nginx配置服务器写接口,前端部署,前后端分离有没有详细的方法

新手上路,请多包涵

node+express+MySQL+Nginx怎么配置服务器写接口,前端vue打包后怎么部署上线,前后端分离有没有详细的方法

阅读 2.4k
2 个回答
怎么配置服务器写接口

这句话什么意思

node+express部分使用PM2
https://github.com/Unitech/pm2

然后nginx配置:

server
  {
    listen 80;
    server_name xxx.com; //你的域名
    ssl_session_timeout 60m;
    index index.html;
    root /home/www/wwwroot/demo/dist;//你的前端的dist目录
    location / {
      try_files $uri $uri/ /index.html =404;
    }
    location ^~/api/ {
      proxy_redirect off;
      #proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass http://127.0.0.1:3000; //转发到你的node+express的项目的地址
    }
  }
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题