Answer the question
In order to leave comments, you need to log in
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
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;
}
}
Answer the question
In order to leave comments, you need to log in
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;
}
location /robots.txt {
root /home/bakotiinii/lieman/faceset/static;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question