Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!