L
L
lexa782020-06-14 20:32:54
Nginx
lexa78, 2020-06-14 20:32:54

Why does nginx redirect to localhost?

Hello! I registered a redirect from http to https in the nginx config.

server {
    listen 443 ssl;

    ssl_certificate /etc/ssl/mysite.ru.crt;
    ssl_certificate_key /etc/ssl/mysite.ru.key;

    server_name mysite.ru;

    root /var/www/web/sites/$host/public;

    index index.php index.html index.htm;

    if ($ssl_protocol = "") {rewrite ^ https://$host$request_uri? permanent;}

}

But, when I go to mysite.ru , there is a redirect to https://localhost
. What could be the reason?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Sundukov, 2020-06-14
@lexa78

The given server is for http s . And you need to look at the server that listen 80. Therefore, the redirect not given here works. We do:
grep -iR listen /etc/nginx | grep 80
and look at the found files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question