なぜかわかりません。nginxwww
URLはにリダイレクトされませんnon-www
。
www
すべてのURLをにリダイレクトしたいですnon-www
。
Nginxはerror.log
次のメッセージを表示します。
2019/05/28 17:45:07 [warn] 21670#21670: conflicting server name "www.my-first-domain.at" on 0.0.0.0:80, ignored
利用可能なサイト
server {
listen 80;
server_name www.my-first-domain.at;
return 301 $scheme://my-first-domain.at$request_uri;
}
server {
listen 80;
server_name www.my-second-domain.at;
return 301 $scheme://my-second-domain.at$request_uri;
}
server {
server_name my-first-domain.at my-second-domain.at;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/futilestudio/myproject;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/my-first-domain.at/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/my-first-domain.at/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 = my-second-domain.at) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = my-first-domain.at) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name 178.128.xxx.xxx my-first-domain.at my-second-domain.at;
return 404; # managed by Certbot
}
wwwではないドメインはうまく動作します。何が問題なのか知っていますか?
編集する
(venv) futilestudio@Brennholz-2:~/myproject sudo nginx -t
nginx: [warn] conflicting server name "www.my-first-domain.at" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.my-second-domain.at" on 0.0.0.0:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful