yaoweibin / ngx_http_substitutions_filter_module

a filter module which can do both regular expression and fixed string substitutions for nginx
607 stars 213 forks source link

Not working while output proxy_pass-ed contents? #4

Closed thislancorp closed 10 years ago

thislancorp commented 11 years ago

Hello, i tried ngx_http_substitutions_filter_module,and enjoyed so much. but some wrong happend,

configuration file part:

    location /subs1 {
            default_type text/html;
            #subs_filter_types  text/html text/css application/x-javascript; 
            subs_filter ([a-zA-Z0-9]).thislancorp.com c$1.thicache.com ir;
            proxy_pass http://www.thislan.com/;
    }

    location /subs2 {
            default_type text/html;
            #subs_filter_types  text/html text/css application/x-javascript; 
            subs_filter ([a-zA-Z0-9]).thislancorp.com c$1.thicache.com ir;
            echo "<link href='//a.thislancorp.com/jpg/attachment/Day_121127/2_1_15b08a48259ad31.css?16' rel='stylesheet'/>\r\n<xxoo>\r\n<link href='//a.thislancorp.com/jpg/attachment/Day_121127/2_1_15b08a48259ad31.css?16' rel='stylesheet'/>"; 
    }

curl debug: [ root @ localhost ] # curl http://127.0.0.1/subs2 <link href='//ca.thicache.com/jpg/attachment/Day_121127/2_1_15b08a48259ad31.css?16' rel='stylesheet'/> <xxoo> <link href='//ca.thicache.com/jpg/attachment/Day_121127/2_1_15b08a48259ad31.css?16' rel='stylesheet'/>

it works normally.

[ root @ localhost ] # curl http://127.0.0.1/subs1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns='http://www.w3.org/1999/xhtml'&gt; <head> <meta charset='utf-8'/> ... <link href='//a.thislancorp.com/jpg/attachment/Day_121127/2_1_15b08a48259ad31.css?16' rel='stylesheet'/> <link href='/favicon.ico?7' rel='shortcut icon'/>

it does not work now.

yaoweibin commented 11 years ago

hi, I am in vocation. I will reply you two days later.

在 2012 年 12 30 日,11:12 下午,"thislancorp" notifications@github.com编写:

Hello, i tried ngx_http_substitutions_filter_module,and enjoyed so much. but some wrong happend,

configuration file part: location /subs1 { default_type text/html;

subs_filter_types text/html text/css application/x-javascript;

subs_filter ([a-zA-Z0-9]).thislancorp.com c$1.thicache.com ir; proxy_pass http://www.thislan.com/; }

location /subs2 {
        default_type text/html;
        #subs_filter_types  text/html text/css application/x-javascript;
        subs_filter ([a-zA-Z0-9]).thislancorp.com c$1.thicache.com ir;
        echo "<link

href='//a.thislancorp.com/jpg/attachment/Day_121127/2_1_15b08a48259ad31.css?16' rel='stylesheet'/>\r\n\r\n<link href='//a.thislancorp.com/jpg/attachment/Day_121127/2_1_15b08a48259ad31.css?16' rel='stylesheet'/>"; }

curl debug: [ root @ localhost ] # curl http://127.0.0.1/subs2

it works normally.

[ root @ localhost ] # curl http://127.0.0.1/subs1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

...

it does not work now.

— Reply to this email directly or view it on GitHubhttps://github.com/yaoweibin/ngx_http_substitutions_filter_module/issues/4.

thislancorp commented 11 years ago

@yaoweibin 解决了。。。是因为后端启用了gzip. 使用

proxy_set_header Accept-Encoding "";

即解决。