nginx反向代理在请求中replace方括号

我有一个redirect循环的问题,反过来由nginx 1.2.1代理的网站。 它看起来像下面的原因(我不知道如何解决)

使用httpfox检查网站,浏览器发送的请求如下所示:

https://www.acme.eu/acm/admin/gui_call.php?Object=admin@GuiAdminStartpage&Params[gui]=&action=&no_subtitle=1

我的nginx日志告诉我这个:

GET 1/acm/admin/gui_call.php?Object=admin@GuiAdminStartpage&params%252525252525252525252525255bgui%252525252525252525252525255d=&action=&no_subtitle=1 HTTP/1.1" HTTP/1.1" 301 486 "https://www.acme.eu/acm/ui/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0.1"

(这一直重复,直到Firefox检测到循环)

对我来说,nginx看起来像是将“gui”的方括号分别改为“252525252525252525252525255b”和“252525252525252525252525255d”。 我认为,因为脚本gui_call.php得到错误的参数,它redirect到/ acm / ui。 / acm / ui用错误的参数调用gui_call.php,依此类推。

如果我的解释是正确的,我怎么能阻止呢? 如果不是,这里发生了什么?

我的网站特定的configuration:

 proxy_cache_path /var/lib/nginx/proxy/cache/www.acme.eu levels=1:2 keys_zone=www.acme.eu-cache:8m max_size=2000m inactive=600m; # http server{ server_name www.acme.eu; listen 80; access_log /var/log/nginx/access_www.acme.eu_80.log; error_log /var/log/nginx/error_www.acme.eu_80.log; proxy_cache www.acme.eu-cache; proxy_cache_valid 200 302 600m; proxy_cache_valid 404 10m; location ~* \.(jpg|gif|png|css|js) { try_files $uri @proxy; } location @proxy { proxy_pass http://www.acme.eu; } location / { proxy_pass http://www.acme.eu; } } # https server{ server_name www.acme.eu; listen 443; ssl on; ssl_certificate /etc/nginx/ssl/acme_eu.crt; ssl_certificate_key /etc/nginx/ssl/acme_eu.key; access_log /var/log/nginx/access_www.acme.eu_443.log; error_log /var/log/nginx/error_www.acme.eu_443.log; proxy_cache www.acme.eu-cache; proxy_cache_valid 200 302 600m; proxy_cache_valid 404 10m; location ~* \.(jpg|gif|png|css|js) { try_files $uri @proxy; } location @proxy { proxy_pass http://www.acme.eu; } location / { proxy_pass http://www.acme.eu; } } 

一般configuration

 user www-data; worker_processes 16; pid /var/run/nginx.pid; events { worker_connections 768; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## access_log /var/log/nginx/access.log; #error_log /var/log/nginx/error.log debug; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; index index.html index.htm ; ## # Proxy Settings ## proxy_temp_path /var/lib/nginx/proxy/tmp; } 

编辑:原来问题是,这一个网站强制SSL,所以我需要定义一个使用SSL的后端。 在后端使用SSL是不是很有用,但这是一个不同的主题:)

原来问题是这个网站强制ssl。 所以,当后端尝试redirect到ssl时,nginx一次又一次地尝试了ssl,导致了redirect循环。

显而易见的解决scheme是将SSL放在nginx中并在后端禁用它。 但是由于我们仍然在testing中,而且后端以普通networking服务器的forms进行生产,所以目前这不是一种select。

我所做的是我定义了一个使用ssl的后端。 在我的位置我有

  location ~* \.(jpg|gif|png|css|js) { try_files $uri @proxy; } location @proxy { proxy_pass https://backend-secure-all-apaches; } location / { proxy_pass https://backend-secure-all-apaches; } proxy_set_header Host $host; 

请注意proxy_set_header Host $host; 这对于获得正确的答案非常重要。 然后我定义了后端,如下所示:

  upstream backend-secure-all-apaches { server 17.123.22.25:443; server 17.123.22.26:443; server 17.123.22.27:443; }