Reputation: 21
my nginx configuration doesn´t match my https server and redirects to the server ip instead.
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name www.example.de example.de;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
include snippets/example.conf;
include snippets/ssl-params.conf;
server_name www.example.de example.de;
root /var/www/html;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ /.well-known {
allow all;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm-butterbirne.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
client_max_body_size 50m;
}
I have added default_server to it because some answers suggested that a default_server is necessary for matching. Http is somehow fine but then it redirects to the machines ip instead. I will write 127.0.0.1 instead of the real ip
root@v22017043237047379:/etc/nginx# curl -I -L http://example.de
HTTP/1.1 301 Moved Permanently
Server: nginx/1.10.3
Date: Mon, 05 Jun 2017 08:30:09 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Location: https://www.example.de/
HTTP/1.1 301 Moved Permanently
Server: nginx/1.10.3
Date: Mon, 05 Jun 2017 08:30:10 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Pingback: https://127.0.0.1/xmlrpc.php
Location: https://127.0.0.1/
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
curl: (51) SSL: certificate subject name 'example.de' does not match target host name '127.0.0.1'
nginx is 1.10.3 and os Debian Jessi
Upvotes: 1
Views: 1385
Reputation: 21
The mistake was something different. The error came from wordpress. It was configured to listen to an ip instead of the domain causing the wrong redirect.
Upvotes: 1