how to set my dns make my web server accessible to the outside world

--I am in cloudflare the DNS name resolves for me correctly to my Linode's public IP

--I can SSH from my local machine to my Linode via the IP

--My website directory is copied directly from the old site

--nginx is running and I reviewed my Linode's iptables --list reports this:

netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 933/nginx: master p
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 832/sshd
tcp 0 0 0.0.0.0:888 0.0.0.0:* LISTEN 933/nginx: master p
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1818/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 933/nginx: master p
tcp6 0 0 :::80 :::* LISTEN 933/nginx: master p
tcp6 0 0 :::22 :::* LISTEN 832/sshd
tcp6 0 0 :::8888 :::* LISTEN 2114/python
tcp6 0 0 ::1:25 :::* LISTEN 1818/master
tcp6 0 0 :::443 :::* LISTEN 933/nginx: master p
tcp6 0 0 :::3306 :::* LISTEN 2274/mysqld

But when I visit my domain,the following error always appears

502 Bad Gateway

What do I need to do to make this work? Thanks!

2 Replies

What you gave was not the output of iptables(8). Just because netstat(1) says you have daemons listening, does not mean that iptables(8) is not blocking traffic…iptables(8) inspects/blocks inbound traffic before a daemon will ever see it. That being said, you should see:

https://www.lifewire.com/502-bad-gateway-error-explained-2622939

I would suggest that your web server is mis-configured. Since I don't know anything about nginx, hopefully someone else will comment.

-- sw

P.S. You write:

--I can SSH from my local machine to my Linode via the IP

Can you do this via the domain name? If not, that's a 99.9%-sure indication your DNS is not set up properly.

In addition to sw's tips, you may find this other Linode Community Questions post to be helpful as you troubleshoot:

How can I fix a 502 Bad Gateway error?

A 502 error is very often the result of a misconfiguration within the web server. If this were a firewall issue, you would probably see a "connection refused" error instead. The steps in this post should help you determine where the issue is occurring.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct