Nginx请求头返回问题
开发需求curl www.xxx.com返回请求,结果得不到请求头
upstream client {
server 172.16.148.115:8080 max_fails=0 fail_timeout=10s;
}
server {
listen 80;
server_name www.xxx.com;
underscores_in_headers on;
access_log /data/nginx/logs/client/client_access.log;
error_log /data/nginx/logs/client/client_error.log;
location / {
proxy_connect_timeout 75;
proxy_read_timeout 300;
proxy_send_timeout 300;
proxy_buffer_size 64k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_pass http://client;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}
1:跨域问题(没有解决)
2:设定自定义请求头(没有解决)
3:underscores_in_headers on;用于开启请求头key支持下划线'_'特殊符号,默认为off(解决!)
最后修改如下:
upstream client {
server 172.116.148.115:8080 max_fails=0 fail_timeout=10s;
}
server {
listen 80;
server_name www.xxx.com;
underscores_in_headers on;
access_log /data/nginx/logs/client/client_access.log;
error_log /data/nginx/logs/client/client_error.log;
location / {
proxy_connect_timeout 75;
proxy_read_timeout 300;
proxy_send_timeout 300;
proxy_buffer_size 64k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_pass http://client;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}
|