Answer the question
In order to leave comments, you need to log in
Django + Nginx why configuration gives hell when indexed by search engines?
Hello, I have a strange problem. There are ten Django sites on the gunicorn + Nginx daemons on the server.
The problem is that after the new site was placed, it began to be indexed under the addresses of other projects. For example.
The new site on the server has the domain name www.1.ru and the title "Site 1"
The following content appears in the search engine
: www.2.ru Site 1
www.3.ru Site 1 404
Nginx configuration
crashes when going to these addresses
server {
server_name www.domain.ru domain.ru;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/domain/domain/;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/domain/domain/domain.sock;
}
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain.ru/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.ru/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = domain.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = www.domain.ru) {
return 301 https://domain.ru;
}
server_name www.domain.ru domain.ru;
listen 80;
return 404; # managed by Certbot
}
Answer the question
In order to leave comments, you need to log in
add a default server for nginx with a stub, then all requests will go to it.
https://nginx.ru/ru/docs/http/request_processing.html
server {
listen 80 default_server;
server_name example.net www.example.net;
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question