S
S
Sergey Nizhny Novgorod2016-09-01 15:56:47
Django
Sergey Nizhny Novgorod, 2016-09-01 15:56:47

How to write robots.txt for nginx in django?

Hello.
For some reason, nginx does not return the robot file:
The file is located in:
home/bakotiinii/lieman/faceset/static/robots.txt
52c2546075c84340b1ab1736883773af.png
nginx settings

server {
        listen 80;
        server_name *****;

        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
            root /home/bakotiinii/lieman;
        }

        location  /robots.txt {
            alias home/bakotiinii/lieman/faceset/static/robots.txt;
        }

        location / {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://unix:/home/bakotiinii/lieman/lieman.sock;
        }
    }

What is the error or how to write it correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Inishev, 2016-09-01
@Terras

It is necessary to register root, relative to which the alias is set.
nginx.org/en/docs/http/ngx_http_core_module.html#root

location  /robots.txt {
            root /home/bakotiinii/lieman/faceset;
            alias /static/robots.txt;
}

Or simply
location  /robots.txt {
            root /home/bakotiinii/lieman/faceset/static;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question