我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