502 Bad Gateway for my www.domain.com


I installed Ghost on my own server.
I’ve already set an A record from the domain pointing at the server’s IP address and ensure that it’s resolving correctly.
I set https://domain.com as my URL configuration and I can visit my website with this URL.
But when I use https://www.domain.com to visit my website, the website shows the 502 bad gateway error.
How can I visit my website with https://domain.com and also https://www.domain.com?

I’m not familiar with SSL and Nginx and I just have followed the setup guide before. Could you please teach me how to make it?


I’ve solved this problem myself with a whole afternoon.
I found a tutorial about redirect https://docs.ghost.org/api/ghost-cli/knowledgebase/#ssl