server {
listen 8000;
server_name somename alias another.alias;
location /a {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Allow-Credentials' 'true';
proxy_redirect off; proxy_pass https://www.oschina.net/news/widgets/_news_index_all_list?p=2&type=ajax;
}
}

  

server {        listen       8000;        server_name  somename  alias  another.alias;            location /a {    add_header 'Access-Control-Allow-Origin' '*';            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';            add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';add_header 'Access-Control-Allow-Credentials' 'true';             proxy_redirect          off;                        proxy_pass https://www.oschina.net/news/widgets/_news_index_all_list?p=2&type=ajax;         }    }

nginx反向代理ajax,解决跨域问题的更多相关文章

  1. 前端使用 Nginx 反向代理彻底解决跨域问题

    引入网址https://blog.csdn.net/larger5/article/details/81286324 1.请求后端数据失败 代码: <!DOCTYPE html> < ...

  2. 简单配置nginx反向代理,实现跨域请求

    简单配置nginx去做反向代理,实现跨域请求 简单介绍nginx的nginx.conf最核心的配置,去做反向代理,实现跨域请求. 更多详细配置,参考nginx官方文档 先介绍几个nginx命令 打开n ...

  3. nginx 反向代理,支持跨域,前后分离

    前端开发往往涉及到跨域问题,其中解决方案很多: 1.jsonp 需要目标服务器配合一个callback函数. 2.window.name+iframe 需要目标服务器响应window.name. 3. ...

  4. Nginx反向代理配置可跨域

    由于业务需要,同一项目中的前端代码放在静态环境中,而后端代码放在tomcat中,但此时问题却出现了:前端使用ajax请求后端获取数据时出现如下报错 XMLHttpRequest cannot load ...

  5. 【Node】node.js实现服务器的反向代理,解决跨域问题

    跨域对于前端来说是一个老大难的问题,许多方法如jsonp.document.domain + iframe...都有或多或少的问题,一个最佳实践就是通过服务器nginx做反向代理,但奈何不懂相关知识, ...

  6. vue反向代理(解决跨域)

    1,vue中有提供反向代理的接口,就是config/index.js中的proxyTable,我的脚手架版本是2.9.6,proxyTable配置初始为空,如下图. 2,将proxyTable配置如下 ...

  7. vue cli3.3 以上版本配置vue.config.js 及反向代理操作解决跨域操作

    const webpack = require('webpack') module.exports = { configureWebpack: { plugins: [ new webpack.Pro ...

  8. Webpack 开发服务器代理设置解决跨域问题

    在前端开发过程中,可能会遇到跨域问题,在 webpack 设置中对 devServer 配置代理即可解决跨域问题,具体设置如下: webpack.config.js module.exports = ...

  9. vue访问外部接口设置代理,解决跨域(vue-cli3.0)

    vue-cli3.0搭建的项目,平时访问内部接口配置了拦截器,今天需要调用天气预报的外部接口,发现跨域问题,通过配置代理解决. 1.在vue.config.js中配置代理 module.exports ...

  10. Vue Nginx反向代理配置 解决生产环境跨域

    Vue本地代理举例: module.exports = { publicPath: './', devServer: { proxy: { '/api': { target: 'https://mov ...

随机推荐

  1. 访问TomCat出现的一些异常

    BUG-01:访问页面时出现: HTTP Status 500 servlet.init() for servlet DispatcherServlet threw exception...... 解 ...

  2. Thymeleaf 在项目中的应用及前后端交互的一些知识(1)

    经过一段时间的工作,我的第一个项目已经快要上线了.本篇文章介绍些thymeleaf在工作中的实际应用,但是更多的还是一些前端处理后台数据的一些思路,如果有什么不正确的地方,希望大家指点. 1.th:e ...

  3. poj1724 ROADS

    题意: N个城市,编号1到N.城市间有R条单向道路.每条道路连接两个城市,有长度和过路费两个属性.Bob只有K块钱,他想从城市1走到城市N.问最短共需要走多长的路.如果到不了N,输出-12<=N ...

  4. Codeforces GYM 100741A . Queries

    time limit per test 0.25 seconds memory limit per test 64 megabytes input standard input output stan ...

  5. saltstack 源码安装

    面向对象编程(oop) 面向对象: 面向对象三大特性: 封装 继承 多肽封装: 封装就是将具体的客观事物封装成抽象的类.并且类可以把自己的数据和方法只让可信的类或者对象操作,对不可行的进行信息隐藏继承 ...

  6. Codeforces Round #539 (Div. 2) C. Sasha and a Bit of Relax(前缀异或和)

    转载自:https://blog.csdn.net/Charles_Zaqdt/article/details/87522917 题目链接:https://codeforces.com/contest ...

  7. cocos2dx 接入bugly 报错 Fail to get class by NSClassFromString(BuglyAgent)

    ios 端安装文档接入库后,报错 -> static void BuglyJSAgent::reportJSError(JSContext *, const char *, JSErrorRep ...

  8. python 人脸识别试水(一)

    1.安装python,在这里我的版本是python 3.6 2.安装pycharm,我的版本是pycharm 2017 3.安装pip  pip 版本10 4.安装 numpy    :pip ins ...

  9. 【vc】高精度时间函数的使用

    方法一: 函数定义如下: int UsSleep(int us);//返回实际的微秒延时时间 代码实现如下: //参数一表示 需要等待的时间 微秒为单位 int UsSleep(int us) { / ...

  10. js中数组删除 splice和delete的区别,以及delete的使用

    var test=[];test[1]={name:'1',age:1};test[2]={name:'2',age:2};test[4]={name:'3',age:3}; console.log( ...