Welcome! Log In Create A New Profile

Advanced

serving certain file for all but one server{}

Posted by ST 
Hello,

I have a lot of server{}s with different server_names all over my setup.
I want to serve robots_closed.txt instead of robot.txt for all but one
domain. And for that one domain, let's say example.org, I want robot.txt
to served normally. What is the right way to achieve that without
writing an explicit redirect in all the server{}s?

Thank you!

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Zhang Chao
Re: serving certain file for all but one server{}
July 30, 2017 01:40PM
Hi!

You can rewrite the uri in the special server {} by the “rewrite” directive.


On 30 July 2017 at 19:09:27, ST ([email protected]) wrote:

Hello,

I have a lot of server{}s with different server_names all over my setup.
I want to serve robots_closed.txt instead of robot.txt for all but one
domain. And for that one domain, let's say example.org, I want robot.txt
to served normally. What is the right way to achieve that without
writing an explicit redirect in all the server{}s?

Thank you!

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
That is the problem - the special server{} (example.org) should serve
robot.txt as is. Those are all the other server{}s that need a redirect
from /robot.txt to /robot_closed.txt. Are there other ways to do that
except for explicit redirect inside of all those server{}s?


On Sun, 2017-07-30 at 04:34 -0700, Zhang Chao wrote:
> Hi!
>
>
> You can rewrite the uri in the special server {} by the “rewrite”
> directive.
>
>
>
> On 30 July 2017 at 19:09:27, ST ([email protected]) wrote:
>
> >
> > Hello,
> >
> > I have a lot of server{}s with different server_names all over my
> > setup.
> > I want to serve robots_closed.txt instead of robot.txt for all but
> > one
> > domain. And for that one domain, let's say example.org, I want
> > robot.txt
> > to served normally. What is the right way to achieve that without
> > writing an explicit redirect in all the server{}s?
> >
> > Thank you!
> >
> > _______________________________________________
> > nginx mailing list
> > nginx@nginx.org
> > http://mailman.nginx.org/mailman/listinfo/nginx
> >
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Francis Daly
Re: serving certain file for all but one server{}
July 30, 2017 08:30PM
On Sun, Jul 30, 2017 at 02:48:05PM +0300, ST wrote:

Hi there,

> That is the problem - the special server{} (example.org) should serve
> robot.txt as is. Those are all the other server{}s that need a redirect
> from /robot.txt to /robot_closed.txt. Are there other ways to do that
> except for explicit redirect inside of all those server{}s?

Just for clarity of what you expect:

A request for http://normal1/robots.txt should return what?

* a http redirect to http://normal1/robot_closed.txt
* a http redirect to http://common/robot_closed.txt
* the content of the file /usr/local/nginx/normal1/html/robot_closed.txt
* the content of the file /usr/local/nginx/html/robot_closed.txt
* something else?

If it is "a" or "c", then presumably a request for
http://normal2/robots.txt should return the equivalent thing; if it is
"b" or "d", then a a request for http://normal2/robots.txt should return
the same thing.

And, a request for http://special/robots.txt should return what?

* the content of the file /usr/local/nginx/special/html/robots.txt
* the content of the file /usr/local/nginx/html/robots.txt

Depending on your answers, maybe the easiest thing would be to rename
"robots.txt" to "robots_special.txt", and rename "robot_closed.txt" to
"robots.txt", and just put a config in the special server{} of the form

location = /robots.txt {alias /usr/local/nginx/html/robots_special.txt;}

Good luck with it,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login