本机下载安装nginx
nginx常用命令:
查看Nginx的版本号:nginx -V
启动Nginx:start nginx
快速停止或关闭Nginx:nginx -s stop
正常停止或关闭Nginx:nginx -s quit
配置文件修改重装载命令:nginx -s reload
在nginx.conf中配置跨域
listen 4000; // nginx代理接口
server_name localhost;
location ^~ /api/ { // 所有/api的接口访问
proxy_pass http://服务器地址xx.xx.xx.xx:xxxx;
}
location ^~ /fe/ { // 所有/fe的接口访问
proxy_pass http://服务器地址xx.xx.xx.xx:xxxx;
}
location / {
proxy_pass http://本机服务地址xx.xx.xx.xx:3000;
}
以上完美解决跨域