"https" in URL but "http" in google search results
I've added a free Let's encrypt SSL certificate using certbot(nginx) to my site. Everything works fine but in google search results my site url is displayed as "http://example.com" but when I open the link, in the page url it is displayed as "https://example.com". How do I get it to display the same https url in google search results. I am provinding my nginx server config.
server {
server_name domain.com www.domain.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/nithish/myproject/home;
}
location /media/ {
root /home/nithish/myproject;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/nithish/myproject.sock;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.com/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 = www.domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name domain.com www.domain.com;
return 404; # managed by Certbot
}