Greetings to all!
I configure the server with two domains. (Suppose: "test.com", "test2.com") When switching to test2.com, an error 400 (Bad request) pops up. If you go to test2.com, it already redirects to test.com ... The most interesting thing is that this 400 Bad request is recorded in the logs of the uwsgi site "test.com". Both sites use redirection from http to https.
Question: Why does he (or not he) redirect to "test.com" rather than to "test2.com"? If Nginx settings are needed, I can attach them.
Configuration "test2.com"
# test2.com upstream django { server unix:///tmp/test2.sock; } server { proxy_set_header Host $host; proxy_set_header X-Forwarded-Host $server_name; listen 80; listen [::]:80; server_name test2.com, www.test2.com; if ($scheme = http) { return 301 https://$server_name$request_uri; #rewrite ^/(.*)$ https://$host/$1 permanent; } } server { listen 443 ssl; listen [::]:443 ssl; server_name test2.com; charset utf-8; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header Host $host; client_max_body_size 75M; error_page 502 /502.html; location = /502.html { root /home/User/html; } location /media { alias /var/www/django/test2/media; } location /static { alias /var/www/django/test2/static; } location / { uwsgi_pass django; include /var/www/django/test2/uwsgi_params; } } Configuration "test.com":
upstream django { server unix:///tmp/test.sock; } # конфигурация веб-сервера server { listen 80 default_server; listen [::]:80 default_server; server_name test.com www.test.com; if ($scheme = http) { return 301 https://$server_name$request_uri; } } server { listen 443 ssl; # доменное имя server_name test.com; charset utf-8; client_max_body_size 75M; error_page 502 /502.html; location = /502.html { root /home/User/html; } location /media { alias /var/www/djangoc/test/media; } location /static { alias /var/www/djangoc/test/static; } location / { uwsgi_pass django; include /var/www/djangoc/test/uwsgi_params; } } UWSGI configuration to the server "test2.com": [uwsgi]
plugin=python3 chdir = /var/www/django/test2 module = test2.wsgi home = /var/www/django/venv master = true socket = /tmp/test2.sock chmod-socket = 666 vacuum = true pidfile2 = /tmp/test2-master.pid logto = /var/log/uwsgi/test2.log daemonize = /var/log/uwsgi/test2.log py-autoreload=5