5. nginx跨域配置
1.跨域问题处理:在nginx相关接口上配置如下: 如接口有自己的请求头,则加上:如接口自带请求头pubacc-buid
if ($request_method = "OPTIONS") {
return 204;
add_header 'Access-Control-Allow-Origin' '$http_origin';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS';
add_header 'Access-Control-Allow-Headers' 'pubacc-buid,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,Accept,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,*';
add_header 'Access-Control-Max-Age' '3600';
}
if ($request_method = "GET") {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'pubacc-buid,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,Accept,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,*';
}
if ($request_method = "POST") {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS';
add_header 'Access-Control-Allow-Headers' 'pubacc-buid,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,Accept,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,*';
}
2.页面返回带有标准端口处理:将标准版端口切换为请求端口
location ^~ /doc-convert {
proxy_set_header Host $http_host;
proxy_set_header x-request-rid $request_id;
proxy_set_header remote_scheme $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1; proxy_set_header Connection "";
proxy_set_header Accept-Encoding "";
proxy_redirect http://$host https://$host;
proxy_pass http://upsdoc-convert;
}
5. nginx跨域配置的更多相关文章
- 014.Nginx跨域配置
一 跨域概述 1.1 同源策略 同源策略是一个安全策略.同源,指的是协议,域名,端口相同.浏览器处于安全方面的考虑,只允许本域名下的接口交互,不同源的客户端脚本,在没有明确授权的情况下,不能读写对方的 ...
- 跨域原因及SpringBoot、Nginx跨域配置
目录 概述 简单请求 跨域解决方案 概述 SpringBoot跨域配置 Nginx跨域配置 概述 MDN文档 Cross-Origin Resource Sharing (CORS) 跨域的英文是Cr ...
- Windows平台下nginx跨域配置
1)下载地址: http://nginx.org 2)启动 解压至d:\nginx,运行nginx.exe(即nginx -c conf\nginx.conf),默认使用80端口,日志见文件夹D:\n ...
- nginx跨域配置
假设前端页面的地址为: 192.168.1.1/arcgis40/index.html 页面物理路径为: X:\nginx-1.9.15\html\arcgis40 那么请求服务时,当ajax代码如下 ...
- nginx跨域配置(windos走过的坑)
nginx下载地址: http://nginx.org/en/download.html 红圈区域是稳定版 解压之后放在文件夹就可以了. 解压后: 注意:这里面有个nginx.exe文件,一般情况下双 ...
- Nginx跨域配置方法
配置文件如下,重点在49~52行 #user nobody; worker_processes ; #error_log logs/error.log; #error_log logs/error.l ...
- nginx 跨域配置
server { listen 80; server_name b.com; location /{ if ( $http_referer ~* (a.com|b.com|c.com) ) { Acc ...
- nginx-springboot-vue前后端分离跨域配置
nginx-springboot-vue前后端分离跨域配置 引言 接着上篇--简单的springboot-vue前后端分离登录Session拦截的demo,其中跨域是通过springboot后端全局设 ...
- windows上 nginx 配置代理服务,配置多域名,以及最简单实现跨域配置
Nginx,不用多说啦,大家都熟悉的不能再熟悉了,它是一款轻量级的高性能Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,最近在本地研究将nginx和resin配合使用,使服务 ...
- Nginx跨域访问场景配置和防盗链
跨域访问控制 跨域访问 为什么浏览器禁止跨域访问 不安全,容易出现CSRF攻击! 如果黑客控制的网站B在响应头里添加了让客户端去访问网站A的恶意信息,就会出现CSRF攻击 Nginx如何配置跨域访问 ...
随机推荐
- MRS_MounRiver安装与驱动相关问题汇总
解决问题如下: MounRiver下载与安装 若MounRiver某些功能不全或插件没安装 MounRiver下载与安装 MRS官网下载:http://www.mounriver.com/downlo ...
- Time Series Analysis (Best MSE Predictor & Best Linear Predictor)
Time Series Analysis Best MSE (Mean Square Error) Predictor 对于所有可能的预测函数 \(f(X_{n})\),找到一个使 \(\mathbb ...
- CAS 悲观锁 乐观锁
前面的偏向锁,轻量级锁,重量级锁都是悲观锁, 都会认为必须要对操作对象进行互斥访问,不然就会产生异常, 所以线程只供一个线程使用,阻塞其他线程,是悲观的 在某些情况下,同步的耗时远大于线程切换的时间, ...
- Windows Server 2016 安装AD和Exchange
一.AD虚拟机操作 1.安装net framework 4.8 下载链接:https://dotnet.microsoft.com/download/dotnet-framework/net48 安装 ...
- xml基本学习
概念:可拓展标记语言.可拓展即标签都是自定义的.标记语言即由标签构成的语言. 功能:存储数据: 配置文件 在网络中传输 语法 基本语法: xml文件后缀名为.xml xml第一行必须定义为文档声明 x ...
- 多重背包问题 II
有 NN 种物品和一个容量是 VV 的背包. 第 ii 种物品最多有 sisi 件,每件体积是 vivi,价值是 wiwi. 求解将哪些物品装入背包,可使物品体积总和不超过背包容量,且价值总和最大.输 ...
- 【TS】class类和接口
class可以用来做数据的存储与回显,能将页面的数据分离出来并提取到class内,函数也可以抽离到class,实例化class进行调用.ts中的class类与js的class类基本相同,不同点在于ts ...
- Centos7-RAID冗余磁盘阵列
转载csdn: Centos7-RAID冗余磁盘阵列_黏住你不让你的博客-CSDN博客
- 内网安全之:黄金&白银票据传递域控制器权限维持
内网安全之:黄金&白银票据传递域控制器权限维持 目录 内网安全之:黄金&白银票据传递域控制器权限维持 1 Golden Ticket 1.1 导出 krbtgt 的 NTLM Hash ...
- Postgres14.4(Docker安装)
Postgres14.4(Docker安装) 一,Docker拉取镜像 docker pull postgres:14.4 #检查镜像是否拉取成功 docker images | grep postg ...