Nginx+Zuul采坑请求头问题和文件上传问题

Nginx+Zuul采坑请求头问题和文件上传问题

村头老杨头

Thu Mar 26

村头老杨头

架构图如下:
架构图

因为请求头中有“_”默认Nginx会忽略掉需要在http中加入underscores_in_headers on;

配置文件

#user  nobody;
user root;
worker_processes  1;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
 
http {

    sendfile        on;
    #tcp_nopush     on;
    include       mime.types;
    default_type  application/octet-stream;
 
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
 
    #access_log  logs/access.log  main;
    client_max_body_size 1024M; #上传文件大小限制

    #tcp_nopush     on;
 
    #keepalive_timeout  0;
    keepalive_timeout 70;  #保持连接的时间,默认65s
    underscores_in_headers on;  #nginx对header name的字符做了限制,默认 underscores_in_headers 为off,表示如果header name中包含下划线,则忽略掉。
 
    #gzip  on;
    tcp_nopush        on;  
    tcp_nodelay       on;  
    gzip              on;  
    gzip_min_length   1000;  
    gzip_buffers      4 8k;  
    gzip_comp_level   9;  
    gzip_proxied      any;  
    gzip_types        application/xml application/javascript application/x-javascript application/atom+xml application/rss+xml;   
	
	
    #配置上游服务器网关端口集群
    upstream  backServer{
	server 192.168.0.2 weight=1; ##zuul的地址1
	server 192.168.0.153  weight=1; ##zuul的地址2
    }
 
 
    server {
        listen       80;
        server_name  www.www.com;
	client_max_body_size 20m;
        location / {
           ### 指定上游服务器负载均衡服务器
	    proxy_pass http://backServer/;
	    client_max_body_size 20m;
	    proxy_set_header X-Real-IP $remote_addr;
	    proxy_set_header Host $host;
	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

评论