502 Bad Gateway beim Hochladen von Dateien (NGINX und NodeJS)

502 Bad Gateway beim Hochladen von Dateien (NGINX und NodeJS)

Ich entwickle eine App, mit der der Benutzer Dateien hochladen kann. Während der Backend-Aufruf einwandfrei zu funktionieren scheint, gibt der Aufruf beim Hochladen von Dateien eine 502 Bad Gateway-Meldung zurück.

Die Dateien werden tatsächlich hochgeladen, aber die Fehlermeldung erscheint. Ich denke, es hat etwas mit meiner Nginx-Konfiguration zu tun, also hoffe ich, dass ihr mir sagen könnt, was ich falsch mache.

Hier ist die Nginx-Fehlerprotokollmeldung

[error] 3807#3807: *138 connect() failed (111: Connection refused) while connecting to upstream, client: 189.62.45.133, server: api-dev.app.com.br, request: "GET /users/pics/5218de9eec94a7bb4467c95219b37b41ec1920420c808d9e11244f8d2a234cd6 HTTP/1.1", upstream: "https://161.35.116.108:2000/users/pics/5218de9eec94a7bb4467c95219b37b41ec1920420c808d9e11244f8d2a234cd6", host: "api-dev.app.com.br", referrer: "https://dev.app.com.br/profile"

Hier ist meine nginx.conf-Datei:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    client_max_body_size 100M;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

Mein conf.d-Ordner ist leer, ich habe jedoch bestimmte Einstellungen in Sites aktiviert.

Hier ist meine app.com.br.conf:

proxy_cache_path  /etc/nginx/cache levels=1:2 keys_zone=nuxt-cache:25m max_size=1g inactive=60m use_temp_path=off;

server {
    listen 80;
    listen [::]:80;
    server_name dev.app.com.br api-dev.app.com.br;
    return 301 https://$server_name$request_uri;
}

server {
    server_name dev.app.com.br;
    index index.html;

    root /opt/siena/App-Web-Nuxt/dist;

    listen [::]:443 ssl ipv6only=on;
    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/dev.app.com.br-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/dev.app.com.br-0001/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    location / {
        try_files $uri $uri/index.html $uri.html;
    }

}


server {
    server_name api-dev.app.com.br;

    listen [::]:443 ssl;
    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/api-dev.app.com.br/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/api-dev.app.com.br/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    location / {
        # more_set_headers 'Access-Control-Allow-Origin: *';
        # more_set_headers 'Access-Control-Allow-Methods: GET,POST,OPTIONS,DELETE,PUT';
        # more_set_headers 'Access-Control-Allow-Headers:DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';

        # Simple requests (simples to fix CORS)
        if ($request_method ~* "(GET|POST)") {
            more_set_headers "Access-Control-Allow-Origin:  *";
        }

        # Preflighted requests
        if ($request_method = OPTIONS ) {
            more_set_headers "Access-Control-Allow-Origin:  *";
            more_set_headers "Access-Control-Allow-Methods: GET, POST, OPTIONS, HEAD";
            more_set_headers "Access-Control-Allow-Headers: Authorization, Origin, X-Requested-With, Content-Type, Accept";
            return 204;
        }

        proxy_read_timeout 300s;
        proxy_connect_timeout 75s;
        proxy_redirect off;
        proxy_pass https://161.35.116.108:2000/;
    }
}

Wenn Sie weitere Fragen zum System und zur Konfiguration haben, lassen Sie es mich bitte wissen.

Dank im Voraus.

verwandte Informationen