M
M
Michael2019-02-14 20:30:24
Nginx
Michael, 2019-02-14 20:30:24

How to make the move from www and without to https?

We transfer all sites to https, there are no special problems.
But with one site I can’t figure out how to do it - the address of the site with www is indicated on the board of the car.
I made the move from www to https in the config in this way

server {
    listen 80;
    server_name www.sitename.ru;
    return 301 https://sitename.ru$request_uri;
}

Now you need to make sitename.ru on https://sitename.ru
Tried as above but there is a port conflict
Question - how to do it right?
Now with this config, the site works on both 80 and 443 ports
server {
        listen 80;
        server_name www.sitename.ru;
        return 301 https://sitename.ru$request_uri;
}



server {
        listen 80;
        listen 443 ssl http2;
        server_name sitename.ru;
        ssl_certificate /etc/letsencrypt/live/sitename.ru/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/sitename.ru/privkey.pem;
        ssl_trusted_certificate /etc/letsencrypt/live/sitename.ru/chain.pem;
        include /etc/letsencrypt/options-ssl-nginx.conf;
        root   /var/www/sitename.ru/web;
..............................

Solution (thanks to Vladislav Lyskov )
server {
        listen 80;
        server_name www.sitename.ru sitename.ru;
        return 301 https://sitename.ru$request_uri;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Lyskov, 2019-02-14
@happy-cat

listen 80;
listen 443 ssl;
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question