VPS Ubuntu CloudPanel: 502 Bad Gateway nginx

416 views Asked by At

I've been trying for a few days to configure my Hostinger vps to be able to put my React website on it. I wanted to use CloudPanel, which promised a quick and easy solution. Unfortunately, when I go to my domain name, I get this error: "502 Bad Gateway nginx" My domain name does point to the vps and I haven't touched the rest of the vps. I've repeated the procedure several times to make sure I haven't missed anything, but it doesn't work. I also tested using 'OpenLiteSpeed Node.js', and when I went to my domain, I had the welcome message displayed. I don't understand why CloudPanel isn't working. Could you help me understand what's missing? Thanks in advance

I tested using 'OpenLiteSpeed Node.js', and when I went to my domain, I had the welcome message displayed. I put the ssl_certificates on the nginx_conf Start nginx

1

There are 1 answers

0
Srini On

Important points to consider:

  1. Place the build folder like /home/<site_user>/htdocs/<domain_name>/<repo_folder>/build properly.
  2. Enter the path in the 'Root Directory' input properly. 1
  3. In nginx config, under location / {} replace proxy_pass http://localhost:{{port}}; by try_files $uri $uri/ /index.html;

Since, the NodeJS app is working but not the react app is because the react app is not being severed in http://localhost:3000. Instead the react app is being severed as static html site. If the react app is being severed in any port, use the same port in the Cloud panel UI instead of doing step 3.

Hope it helps!

enter image description here