去官网下载nginx稳定版
如果ajax请求的完整接口为http://192.168.1.545/login;
打开nginx/conf/nginx.conf文件,修改配置文件
listen 代表打开的端口,root代表html文件所在的位置;index 代表跨域文件的名字
proxy——pass代表请求的接口
html中ajax的url为‘/login’;
location /login代表遇到接口中有/login的接口都替换为proxy——pas中的接口;
配置完毕,在nginx文件运行start nginx,启动nginx
访问localhost:8899/html/1111.html
指令重启nginx:nginx -s reload
停止nginx: nginx -s stop