- 前端代码粘贴到服务器 例如:
2.到 /etc/nginx,新建 vhosts (不用vhosts也可以,直接在nginx里面配置,但是好像不能同时使用80端口)
3.在vhosts里面新建几个.conf
4./etc/nginx/下的 nginx.conf,最下面,添加一句配置
include /etc/nginx/vhosts/*.conf;
这句的意思是: 引入 vhosts/里面的config
5.Vhosts 下的配置,比如am.conf
红框是重点
listen 80; //监听端口
server_name am.dev.tuimu.com; //域名
access_log /var/log/nginx/am.log main; //log位置
index index.html index.htm; //指定index页面
location ^~/api { //把 server_name+/api这段指向接口(Tomcat里的项目)
proxy_pass http://10.50.96.29:8087/lieni-app-web-am/;
}
location ^~/ { //前端代码所在目录,index.html同级
root /deploy/www/lieni-www/web-am/src;
}
6.Host配置成nginx所在ip, 浏览器访问server_name. hr/hd等同理,可以用80端口