Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Given the following configuration of nginx:

server {
    listen  80;
    server_name apilocal;
    sub_filter  "apiupstream/api" "apilocal";
    sub_filter_once off;
    location /people/ {
            proxy_pass  http://apiupstream/api/people/;
            proxy_set_header Accept-Encoding "";
    }
}

Sub_filter does not properly response parts of the response. Once I remove proxy_pass from the configuration, it works properly. A lot of folks with this problem end up having gzip compression from the upstream server. I've verified that my upstream server does not have gzip encoding turned on for its responses. But just in case, I've also used the proxy_set_header above to not accept gzip.

Is there potentially something else I'm missing?

share|improve this question

2 Answers 2

up vote 1 down vote accepted
+50

Your response probably has other content-type than defined in sub_filter_types by default.

Reference: http://nginx.org/r/sub_filter_types

share|improve this answer
    
This was the ticket, thank you! –  kylehayes Oct 28 '13 at 14:10
    
I didn't have proxy_set_header Accept-Encoding ""; you need that to tell the backend that compression isn't allowed in a response. –  Doc Oct 7 at 3:19

does it need to be inside a location block? also, maybe no quotes on match arg?

http://wiki.nginx.org/HttpSubModule

location / {   sub_filter      
      </head>   
      '</head><script
      language="javascript" src="$script"></script>';   
      sub_filter_once on;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.