Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

264
Visualizações
Cannot reach localhost from angular application configured inside nginx

I have an application developed by angular as frontend and spring boot for the backend.

I deployed them in Nginx running in Ubuntu server including let's encrypt ssl certificates

The front end is deployed in the following path /var/www/my-app-domain.local The backend is a jar which is running on port 8080

The Nginx configuration is in following file located in /etc/nginx/conf.d/my-app-domain.local.conf

server {
        listen 80;
        listen [::]:80;

        server_name my-app-domain;

        location /api/ {
             proxy_pass http://localhost:8080/;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header X-Forwarded-Proto $scheme;
             proxy_set_header X-Forwarded-Port $server_port;
        }
}

server {
    server_name my-app-domain www.my-app-domain; # managed by Certbot
    index index.html;
    root /var/www/my-app-domain.local;
    location / {
        #        try_files $uri $uri/ =404;
         try_files $uri $uri/ /index.html;
    }



    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/my-app-domain/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/my-app-domain/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot



}server {
    if ($host = my-app-domain) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = my-app-domain) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80 ;
    server_name my-app-domain www.my-app-domain;
    return 404; # managed by Certbot

}

When I call the domain name in the browser, it rejected the call for the API from the webapp showing this error in the console : Failed to load resource: net::ERR_CONNECTION_REFUSED for calling http://localhost:8080/api/*****

However, when I call the same API from the browser, it's calling successfully without any issues.

Is my Ngnix configuration incorrect? what should I do with this error and what is the proper way for calling APIs in production environment?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda