Nginx自定义携带header头

简介: 开发小程序时在header中添加参数被nginx进行拦截

在安装好nginx后打开nginx的配置文件.或者打开指定vhost的配置文件.如果不知道文件位置的话可以使用:
nginx -t

nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful

那么打开配置文件
vim /usr/local/etc/nginx/nginx.conf
添加
underscores_in_headers on;
`add_header Access-Control-Allow-Origin $http_origin;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' '*';
add_header Access-Control-Allow-Headers 'XMLHttpRequest, X_FILENAME, accept-encoding, authorization, content-type, dnt, origin, appid, user-agent, x-csrftoken, x-requested-with, cache-control, from, postman-token, x-http-appid, x-http-device, Pragma, farmorg, orgcode,token,app-id,app_id';`

保存退出后重启nginx即可.

目录
相关文章
|
11月前
|
应用服务中间件 nginx
nginx优化:URI过长或request header过大导致400或414报错
当出现URI过长或请求头过大导致400或414报错时,可以通过以下方式对Nginx进行优化: 1. 调整client_max_body_size参数:该参数用于限制请求体的大小。默认情况下,Nginx的client_max_body_size参数设置为1M。如果请求体超过这个大小,Nginx会返回400错误。您可以根据实际需求适当增加这个值,例如设置为10M或更大。 ``` http { client_max_body_size 10M; } ``` 2. 调整large_client_header_buffers参数:该参数用于调整请求头缓冲区的大
3279 0
|
3天前
|
自然语言处理 大数据 应用服务中间件
大数据-172 Elasticsearch 索引操作 与 IK 分词器 自定义停用词 Nginx 服务
大数据-172 Elasticsearch 索引操作 与 IK 分词器 自定义停用词 Nginx 服务
21 5
|
9天前
|
Docker 容器
docker nginx-proxy 添加自定义https网站
docker nginx-proxy 添加自定义https网站
19 4
|
2月前
|
Ubuntu 搜索推荐 应用服务中间件
如何在 Ubuntu 14.04 上配置 Nginx 使用自定义错误页面
如何在 Ubuntu 14.04 上配置 Nginx 使用自定义错误页面
43 2
|
2月前
|
运维 安全 应用服务中间件
运维系列.Nginx:自定义错误页面(一)
运维系列.Nginx:自定义错误页面(一)
341 1
|
3月前
|
负载均衡 算法 应用服务中间件
nginx自定义负载均衡及根据cpu运行自定义负载均衡
nginx自定义负载均衡及根据cpu运行自定义负载均衡
43 1
|
2月前
|
缓存 运维 应用服务中间件
运维系列.Nginx:自定义错误页面(二)
运维系列.Nginx:自定义错误页面(二)
59 0
|
2月前
|
应用服务中间件 nginx
[nginx]日志中记录自定义请求头
[nginx]日志中记录自定义请求头
|
4月前
|
应用服务中间件 nginx
Nginx 配置,自定义日志格式 log_format
Nginx 配置,自定义日志格式 log_format
153 0
|
应用服务中间件 nginx
nginx输入请求的header和body到日志
nginx输入请求的header和body到日志
600 1