nexcess / magento-turpentine

A Varnish extension for Magento.
GNU General Public License v2.0
519 stars 253 forks source link

url_base_regex make this plugin do not work correctly. #1154

Open yssource opened 8 years ago

yssource commented 8 years ago

Hi, I use the nginx working as reverse proxy to apache httpd. my vanish version is vcl 4.0 and magento 1.9.2.4 with multi-language store I replace my /etc/varnish/default.vcl file with the default.vcl from magento-admin -> system -> cache Management -> "Download the generated VCL file"

## if this line works for me
if (req.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed)\.php/)?") {
## if this line the magento website display a blank site
#if (req.url ~ "^(/index\.php/second2/|/index\.php/fourth/|/index\.php/pt_br/|/index\.php/es_es/|/index\.php/ja_jp/|/index\.php/ru_ru/|/index\.php/fr_fr/|/index\.php/tr_tr/|/index\.php/it_it/|/index\.php/ar_eg/|/index\.php/th_th/|/index\.php/sixth/|/index\.php/de_de/|/index\.php/zh_cn/|/index\.php/third/|/index\.php/en_us/|/index\.php/fifth/|/media/|/skin/|/js/)(?:(?:index|litespeed)\.php/)?") {
set req.http.X-Turpentine-Secret-Handshake = "1";
if (req.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed)\.php/)?admin") {
#if (req.url ~ "^(/index\.php/second2/|/index\.php/fourth/|/index\.php/pt_br/|/index\.php/es_es/|/index\.php/ja_jp/|/index\.php/ru_ru/|/index\.php/fr_fr/|/index\.php/tr_tr/|/index\.php/it_it/|/index\.php/ar_eg/|/index\.php/th_th/|/index\.php/sixth/|/index\.php/de_de/|/index\.php/zh_cn/|/index\.php/third/|/index\.php/en_us/|/index\.php/fifth/|/media/|/skin/|/js/)(?:(?:index|litespeed)\.php/)?admin") {
set req.backend_hint = admin;
return (pipe);
}
## if this, it works for me
if (req.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed)\.php/)?") {

My problem is 
## if I input "http://magento.dev/", the magento website display a blank site
## if I input "http://magento.dev/index.php/zh_cn/", this line the magento website work normally again.
if (req.url ~ "^(/index\.php/second2/|/index\.php/fourth/|/index\.php/pt_br/|/index\.php/es_es/|/index\.php/ja_jp/|/index\.php/ru_ru/|/index\.php/fr_fr/|/index\.php/tr_tr/|/index\.php/it_it/|/index\.php/ar_eg/|/index\.php/th_th/|/index\.php/sixth/|/index\.php/de_de/|/index\.php/zh_cn/|/index\.php/third/|/index\.php/en_us/|/index\.php/fifth/|/media/|/skin/|/js/)(?:(?:index|litespeed)\.php/)?") {

Why does this happen? Is there any help for me? Thanks a lot.

yssource commented 8 years ago

since, I use nginx working as reverse proxy, which will rewrite / to /index.php. in my config file.

    location @handler {
        #rewrite / /index.php?$args;
        rewrite ^/(.*)$ /index.php/$1 last; ## very important, append all index.php before $uri
        #rewrite / /index.php;
    }

And I try to fix my personal problem by adding "/index.php/?|" , and it works for me.

if (req.url ~ "^(/index\.php/?|/index\.php/second2/|/index\.php/fourth/|/index\.php/pt_br/|/index\.php/es_es/|/index\.php/ja_jp/|/index\.php/ru_ru/|/index\.php/fr_fr/|/index\.php/tr_tr/|/index\.php/it_it/|/index\.php/ar_eg/|/index\.php/th_th/|/index\.php/sixth/|/index\.php/de_de/|/index\.php/zh_cn/|/index\.php/third/|/index\.php/en_us/|/index\.php/fifth/|/media/|/skin/|/js/)(?:(?:index|litespeed)\.php/)?") {

So, I'm not sure this is caused by the variable "url_base_regex" setting or not?