码迷,mamicode.com
首页 > 其他好文 > 详细

nginx跨域配置

时间:2016-12-01 11:53:40      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:proxy   error:   html   nbsp   前端   gis   function   ring   param   

假设前端页面的地址为:

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跨域配置

标签:proxy   error:   html   nbsp   前端   gis   function   ring   param   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!