被调用方解决方案-Nginx解决方案
1、 最常见的Java EE架构

2、下载安装Nginx(Windows版本)
(1)下载地址
http://nginx.org/en/download.html
(2)下载安装流程



(3)配置本地环境变量

(4)验证是否安装成功

3、本地虚拟域名配置
(1)找到对应hosts文件路径

(2)修改hosts配置文件

4、Nginx代理服务器配置
(1)创建一个虚拟主机目录

(2)创建一个b.com.conf配置文件

(3)修改nginx.conf配置

(4)验证nginx.conf配置是否合法

(5)启动nginx

(6)查看是否启动nginx

(7)验证是否nginx实现请求代理转发

5、后端CrossFilter跨域设置改成Nginx配置
(1)后端Filter注册代码全部注释

(2)使用Nginx配置替换

server{
listen80;
server_namewww.test.com;
location/ {
proxy_passhttp://localhost:8081/;
#proxy_set_headerHost $host:80;
#proxy_set_headerX-Real-IP $remote_addr;
#proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for;
add_headerAccess-Control-Allow-Origin $http_origin;
add_headerAccess-Control-Allow-Methods *;
add_headerAccess-Control-Allow-Headers $http_access_control_request_headers;
add_headerAccess-Control-Max-Age 60000;
add_headerAccess-Control-Allow-Credentials true;
if($request_method = OPTIONS){
return200;
}
}
}
(3)验证是否解决跨域问题

网友评论