Forum: NGINX Help with code

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
04a503a96d819e91d2080896e3fe4ea3?d=identicon&s=25 Nick Toseland (Guest)
on 2013-07-22 17:39
(Received via mailing list)
Hi All,

I have the following code:

                location = /favicon.ico {
                        if ($host = "abc.com"){
                            return 301 "http://www.abc.com/favicon.ico";
                        }
                }

If I make a request to abc.com/favicon.ico I get a 301 and then a 200 OK

However the issue is that if I make a request to xyz.abc.com/favicon.ico
I get a 404 as it passes the first match statement but fails the second
and trys to get the favicon resource from the nginx root directory

Is there a better way of doing it so it continues on to be evaluated by
the other rules? or Is there a better way of writing this part of the
code?

Thanks in advance.

Nick
5897ccfea0a62691f880792a3b417bbe?d=identicon&s=25 Jan Algermissen (Guest)
on 2013-07-22 18:10
(Received via mailing list)
On 22.07.2013, at 17:39, Nick Toseland <nick@livejournalinc.com> wrote:

> If I make a request to abc.com/favicon.ico I get a 301 and then a 200 OK
>
> However the issue is that if I make a request to xyz.abc.com/favicon.ico I get a
404 as it passes the first match statement but fails the second and trys to get
the favicon resource from the nginx root directory

Why should the check process even go inside the if, given that
xyz.abc.com is not host abc.com?

Jan
This topic is locked and can not be replied to.