nginx e https: nginx: [emerg] host não encontrado no upstream

3

Antes de mais nada, desculpe-me se esse problema é simples.

Eu tenho um servidor com Ubuntu e nginx nele. Sempre funciona enquanto http é usado, mas depois que eu adicionei certificados e tentei ativar https , recebi esse erro nginx: [emerg] host not found in upstream "api" .
Aqui está minha configuração:

upstream api {
    least_conn;
    server 176.9.91.243:7123;
}

upstream api2 {
    least_conn;        
    server 176.9.32.170:7123;       
}

server {
#   listen 80;
    listen 443;

    ssl on;

    ssl_certificate /etc/ssl/chain.crt;
    ssl_certificate_key /etc/ssl/ssl_key.key;

    add_header Strict-Transport-Security "max-age=31536000";
    add_header Content-Security-Policy "block-all-mixed-content";


    root /var/www/hosting;

    index index.html index.htm;
    client_max_body_size 15m;

    server_name serverName.com;
    gzip  on;
    gzip_min_length 1000;
    gzip_proxied    expired no-cache no-store private auth;
    gzip_types    text/plain application/javascript application/x-javascript text/javascript text/xml text/css;

    set $const 1;



    location /signalr {
        limit_conn addr 1000;
        access_log off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass https://api2/signalr;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
            proxy_read_timeout 120s;
            proxy_buffering off;
            keepalive_timeout 120s;
    }


    location /api/signalr {
        limit_conn addr 1000;
            access_log off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass https://api2/signalr;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
            proxy_read_timeout 120s;
            proxy_buffering off;
            keepalive_timeout 120s;
    }



    location /api/notifications{
        limit_conn addr 1000;
            access_log off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass https://api2/notifications;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
            proxy_read_timeout 120s;
            proxy_buffering off;
            keepalive_timeout 120s;
    }


    location /api/notificationhistory{
        limit_conn addr 1000;
        access_log off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass https://api2/notificationhistory;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
            proxy_read_timeout 120s;
            proxy_buffering off;
            keepalive_timeout 120s;
    }


        location /api/swagger {    
        access_log off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass https://api/swagger;
            proxy_ssl_session_reuse off;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_read_timeout 120s;
            proxy_buffering off;
            keepalive_timeout 120s;

        }


    location /api {
    limit_conn addr 3000;
      rewrite /api(.*) /$1  break;
      proxy_read_timeout 60s;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-NginX-Proxy true;
      proxy_pass https://api;
      proxy_ssl_session_reuse off;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      #access_log /var/log/nginx/api-access.log upstreamlog;
    }

}

O problema só acontece com api upstream enquanto api2 funciona bem. Se eu usar o IP diretamente em proxy_pass , também funciona. O que eu perdi? Obrigado.

    
por Kopleman 07.07.2017 / 10:18

0 respostas

Tags