当使用nginx代理到apache时,保留多个斜线和所有的斜线

所以有一点背景。 我正在将网站从使用Apache的旧服务器迁移到使用NGINX代理到Apache的新Ubuntu服务器。 将有一个过渡期,网站代码库将在新老服务器上运行。

该网站的searchurl与filter是斜杠分开,往往是可选的,例如

www.example.com/search/deals/q1/q2/q3/q4/q5/q6/

它映射到以下apache.conf重写规则:

RewriteRule ^/search/deals/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ /results.php?q1=$1&q2=$2&q3=$3&q4=$4&q5=$5&q6=$6 [L,QSA] 

有像下面的url是不寻常的

www.example.com/search/deals/q1////q5/q6/

www.example.com/search/deals/q1/q2/q3///q6/

www.example.com/search/deals/q1/q2/q3/q4///

在新服务器上,我configuration了NGINX,如下所示:两个站点启用了默认的服务器apache文件和example.com文件

 /etc/nginx/sites-enabled/apache -> ../sites-available/apache /etc/nginx/sites-enabled/example.com -> ../sites-available/example.com 

Apache看起来像这样(真正的IP由10.10.10.10取代):

 server { listen 10.10.10.10:80 default_server; merge_slashes off; #have tried with/without location / { proxy_redirect off; #have tried with/without port_in_redirect off; #have tried with/without proxy_pass http://10.10.10.10:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; } } 

example.com看起来像这样

 server { listen 10.10.10.10:80 ; server_name example.com www.example.com; root /var/www/live/example.com/frontend/htdocs; merge_slashes off; location / { fastcgi_pass unix:/var/run/php5-fpm.sock; #have tried with/without include fastcgi_params; #have tried with/without proxy_redirect off; #have tried with/without port_in_redirect off; #have tried with/without proxy_pass http://10.10.10.10:8080 ; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;#have tried with/without proxy_set_header X-Accel-Internal /internal-nginx-static-location; #have tried with/without access_log off; } } 

在做任何改变之后,我已经通过重启NGINX

 service nginx restart 

当我加载页面,例如www.example.com/search/deals/q1/q2////q6/我得到'文件未find',然后看看日志级别设置为3的Apache日志我得到下面:

 [Wed Oct 07 22:52:10.178436 2015] [rewrite:trace1] [pid 4186:tid 123456789] mod_rewrite.c(468): [client 10.10.10.10:33468] 10.10.10.10 - - [www.example.com/sid#sddsaddsa][rid#sddsaddsa/subreq] pass through /search/deals/q1/q2/q5/ 

这表示所有多个斜线已经通过代理在某个点被剥离。 但是我需要URL保持不变,以便Apache规则可以正确地路由参数。

我曾经看过类似职衔的其他答案,但他们没有一个能够解决我的问题,例如: 与乘客一起工作时保持双重斜线

https://stackoverflow.com/questions/4320774/nginx-how-to-keep-double-slashes-in-urls

https://stackoverflow.com/questions/14832780/nginx-merge-slashes-redirect

https://stackoverflow.com/questions/22759345/nginx-trailing-slash-in-proxy-pass-url

https://stackoverflow.com/questions/5834025/how-to-preserve-request-url-with-nginx-proxy-pass

如果有人有任何build议,或可以指出我的方向是正确的,这将是伟大的?

提前致谢