Setting header for fastcgi response

Hi,

In my nginx config, I have a virtual path (/foo), e.g.

location = /foo {
expires 1h;
add_header Cache-Control “public”;
}

This path does not exist, and it goes into the fcgi using

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~* .php$ {

}

The problem is the 1st location block is adding 404 to every response
even
I can route the request to the backend.

E.g.

curl -v ‘http://www.example.com/foo

< HTTP/1.1 404 Not Found
bar <-- actual output from backend, but why 404?

Any idea?

On Sat, Nov 24, 2012 at 01:58:16PM +0800, howard chen wrote:

Hi there,

in nginx, one request is handled in one location.

location = /foo {
expires 1h;
add_header Cache-Control “public”;
}

Your request for /foo should be handled in that location. It will,
depending on the configuration that you haven’t shown, try to serve the
file /usr/local/nginx/html/foo with a few extra http headers.

This path does not exist, and it goes into the fcgi using

location / {
try_files $uri $uri/ /index.php?$args;
}

The configuration you have shown does not indicate that that will
happen.

(Unless, perhaps, you have something like an error_page directive
in place.)

curl -v ‘http://www.example.com/foo

< HTTP/1.1 404 Not Found
bar <-- actual output from backend, but why 404?

Any idea?

Can you provide a config file that is enough to demonstrate what you
are reporting?

Thanks,

f

Francis D. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs