M
M
Michail Wowtschuk2017-03-02 19:50:28
Nginx
Michail Wowtschuk, 2017-03-02 19:50:28

How to tell nginx that the robots.txt file is on another server?

Hi everyone, there is a site site.com moved all the statics to a separate site.info server,
but I can’t configure nginx to give the robots.txt file from the site.info site when requesting it to site.com/robots.txt.
Tried:

location /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
        alias http://site.info/robots/robots.txt;
 }

and
location /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
        return 301 http://site.info/robots/robots.txt$request_uri;
 }

It turned out like this, but it seems to me that this is not correct, it just happens to be thrown to another site
location /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
        return http://site.info/robots/robots.txt;
 }

Tell me, maybe there are some options to not just transfer to another site, but to make an alias?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wexter, 2017-03-02
@wowtschuk

alias - specify a different folder on this server.
either use return for a redirect or proxy_pass, then nginx will pull the file from another server and give it to the client

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question