0

Getting 502 Bad gateway error after searching with domain

But It's working fine with public IP as below server is running in public IP

And I have created a subdomain with route 53 and then assigned A record with instance public IP But when I ping the domain and IP it's getting request time out and all packets were lost. My application is node express app.So please it's a huge favor if anyone can solve this issue.

Krishan DKM
  • 29
  • 1
  • 1
  • 7

1 Answers1

0

From your screenshot, I found that you're using Nginx as a Reverse proxy. So it might be because of your Nginx config

example your Nginx config may look like this,

server {
    listen 80;
    server_name 192.168.1.21;
    ...
}

you've to update it to:

server {
     listen 80;
     server_name subdomain.domain.com;
     ...
}
Sam
  • 4,046
  • 8
  • 31
  • 47
  • Hi @Sam I have updated it already like below server { listen 80; server_name alpha001.woworderz.com; location / { proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_redirect off; } } – Krishan DKM May 30 '20 at 09:38
  • @KrishanDKM your application is running on port 5000 right? then you are forwarding to 8080? I can find it from your config that you are forwarding to 127.0.0.1:8080 – Sam May 30 '20 at 09:42
  • Yeah So what can I do to fix this? – Krishan DKM May 30 '20 at 09:44
  • @KrishanDKM change it to 127.0.0.1:5000 and restart/reload nginx – Sam May 30 '20 at 09:45
  • Sure I'll try this. Should I reboot the instance? or is it enough to reload the nginx? – Krishan DKM May 30 '20 at 09:53
  • It's still the same. Anything wrong with my subdomain pointing? – Krishan DKM May 30 '20 at 09:59
  • @KrishanDKM No problem with subdomain pointing, if so then it won't reach your server at all. Please check Nginx logs for more information – Sam May 30 '20 at 12:04
  • Hi @Sam Sure I'll check. Thank you for your guidance. – Krishan DKM May 30 '20 at 13:11