I cannot deploy Strapi in my Nginx Server

System Information
  • Strapi Version: 3.6.5
  • Operating System: Ubuntu 20.04 LTS
  • Database:
  • Node Version: v12.22.10
  • NPM Version: 8.5.1
  • Yarn Version:

Good day, I’m writing to you because I’m desperate. I don’t know why my server don’t response to anything. I’ve proved everything and always give me 502. It should be noted that it gives me 502 when I consult the page with ip, because when I consult with dns it does not show me anything, only ''this page cannot be reached"

This is my server.js

module.exports = ({ env }) => ({
  host: env('HOST', '0.0.0.0'),
  port: env.int('PORT', 1337),
  url: env('URL', 'http://localhost:1337'),
  admin: {
    auth: {
      secret: env('ADMIN_JWT_SECRET', 'reserved')
    },
  },
});

thit is etc/nginx/sites-available/strapi.conf

upstream backend {
server 127.0.0.1:1337;
keepalive 64;
}


server {
    # Listen HTTP
    listen 80;
    server_name felucia.estarguars.org;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    # Proxy Config
    location / {
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass_request_headers on;
        proxy_pass http://backend;
        proxy_redirect off;
        proxy_read_timeout 240s;
    }
}

and I get in error log this

*6 connect() failed (111: Connection refused) while connecting to upstream, client: 193.22.84.90, server: felucia.estarguars.org, request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:1337/”, host: “37.218.241.100:80”

Please help T_T


try set:
{
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://backend;
}

BTW: Does your backend(Strapi) server and nginx server in same server?

I prove with that set and still doesn’t work :frowning:
And yes, my nginx server is the same of my backend server.