'Nginx:504 Gateway Timeout

I am using Nginx as my https server to serve my http content from my node server.

I am also hosting my server on google cloud.

I have been keep getting a 504 Gateway Timeout Error; So I wonder if it is because I didnt set my upstream server (node server) 8080 port open. Then it works. Not so sure if it is the correct way to do it

enter image description here

But then I kept looking other docs or tutorial online. I never see people configure in such way to connect to node server. They mainly only left the port 80 opened. So I wondered if my config in server block causing the 504 gateway problem

enter image description here

enter image description here

----------second update

this is my setting, and the default_server is written by default enter image description here

but i always see doc have included a variable - server_name ; Actually I dont quite understand this varibale. May I know should I consider it or not for later use, although it works now

enter image description here

Aside, I got an Server Error from my app.

FetchError: request to https://34.96.213.54:443/search/guest2 failed, reason: self-signed certificate

enter image description here

Why is that it works on chrome,although I get that api directly and postman successfully.

third updated------ enter image description here



Solution 1:[1]

About self-signed certificate: You need to buy one or using a free service like https://letsencrypt.org .Beside that your questions are so basic so you have to research more on nginx docs (http://nginx.org/en/docs/http/server_names.html)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 buithienquyet