
當使用我的瀏覽器時,我會調用http://myhost/tiles/yellow/1/2/3.png,我希望從中獲得內容http://myhost/cache/yellow.png 我的配置如下
location /cache/ {
alias /my/path/cache/;
}
location /tiles/ {
try_files $uri $uri/ @rulestiles;
}
location @rulestiles {
rewrite "^/tiles/([a-zA-Z1-9]*)/[0-9]{2}/[0-9]{6}/[0-9]{6}\.png$" /cache/$1\.png permanent;
}
我想念什麼?是因為我不需要所有參數,所以沒有到處使用 capture 嗎?
我也不想使用符號鏈接,因為我只需要數百個真實文件就需要數億個符號鏈接......
感謝您的任何指導/幫助
答案1
感謝 Alexey Ten
我的問題中的評論,我能夠糾正我的各種錯誤。
首先,我的正規表示式是錯誤的,所以我在測試時沒有捕獲參數
然後,我也更改rewrite
為proxy_pass
保持我的網址相同
location /cache/ {
alias /my/path/cache/;
}
location ~ "/tiles/(?<section>[a-zA-Z1-9]*)/[0-9]{1,2}/[0-9]{1,6}/[0-9]{1,6}.png$" {
proxy_pass http://my.tested.ip.code/cache/$section.png;
proxy_set_header Host $host;
}
my.tested.ip.code
伺服器IP在哪裡。