我nginx的以下配置承载我的形象服务:重写查询字符串路径参数
upstream thumbor {
server localhost:8888;
}
server {
listen 80;
server_name my.imageserver.com;
client_max_body_size 10M;
rewrite_log on;
location ~ /images {
if ($arg_width="10"){
rewrite ^/images(/.*)$ /unsafe/$1 last;
}
rewrite ^/images(/.*)$ /unsafe/$1 last;
}
location ~ /unsafe {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HOST $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://thumbor;
proxy_redirect off;
}
location = /favicon.ico {
return 204;
access_log off;
log_not_found off;
}
}
我试图改写以下网址:从
至
这是很容易的,问题开始时我想允许查询字符串应该去URL的路径,像这样:
从
至
此外它会更好,如果查询字符串的顺序无关紧要。
我试过使用: $ arg_width但它似乎没有工作。
在Ubuntu上使用nginx 1.6.1。
帮助将非常感激。
请出示你现在所拥有的。我怀疑你没有逃过问号,但很难看到你的错误在哪里...... – Melvyn 2014-09-12 06:46:32
这就是我目前的情况,我尝试了几种方法,包括$ arg_width,$ arg_height,但它没有奏效。 – Afiku 2014-09-14 11:14:27