首页 > 其他 > 详细

nginx跨域配置

时间:2016-12-01 11:52:09      阅读:226      评论:0      收藏:0      [点我收藏+]

假设前端页面的地址为:

192.168.1.1/arcgis40/index.html

页面物理路径为:

X:\nginx-1.9.15\html\arcgis40

那么请求服务时,当ajax代码如下时:

 

$.ajax({
type: "GET",
dataType:"json",
url: "getVector/all/1/2/3",
success: function (data) {
alert(JSON.stringify(data));
},
error: function (msg) {
alert(JSON.stringify(msg));

}
});

实际发出的get地址为:192.168.1.1/arcgis40/getVector/all/1/2/3

 

那么在nginx.conf 中这样配置

location /arcgis40/getVector {
rewrite ^.+arcgis40/getVector/(.*)$ /$1 break;
include uwsgi_params;
proxy_pass http://localhost:5000/;
}

 

http://localhost:5000/  为服务端ip地址

服务端的实际接口地址为:http://localhost:5000/all/1/2/3

 

nginx跨域配置

原文:http://www.cnblogs.com/flanker521/p/6121170.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!