Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
How to serve two back-end applications running on different ports with Nginx location?

Boot and angular front-end applications are running on docker containers. I do own a domain and with Nginx reverse proxy to pass the requests for appropriate front-end, back-end which is spring-boot. Default 80 is serving my front-end for more clarification.

Pre details:

Sample domain  : xyz.com
Front-end app  : running on default port 80  
Back-end spring-boot app: running on port 8085

First part of my Nginx configuration:

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

    server_name xyz.com;


    location / {
            root /var/www/site;
            try_files $uri $uri/ /index.html;


    location /api{
            proxy_pass http://localhost:8085;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header connection "upgrade";
    }

}

When I type xyz.com my website is up and running and some front-end routes:

: xyz.com/blogs
: xyz.com/images
: xyz.com/news

These are my rest routes in springboot back-end:

: xyz.com/api/article/getAll
: xyz.com/api/public/mail/sendmail

The interesting part is I can't serve my backend application which is running on port 8085.

This means whenever my URL comes with /api/* it should go to port 8085 but in my case it says "404 not found".

Why are my rest routes not working, did I miss something in my Nginx configuration?

Note: Spring boot container is working fine no issues in docker or application, I think the problem is from Nginx configuration particularly location block.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The block is serving the / first followed by the /api. This should be reversed and then things will work normally.

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

    server_name xyz.com;

    location /api{
            proxy_pass http://localhost:8085;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header connection "upgrade";
    }

    location / {
            root /var/www/site;
            try_files $uri $uri/ /index.html;
    }

}

I had the same issue and got it resolved that way. Refer to NGINX reverse proxy for multiple locations not working for more help.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda