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

223
Views
Nginx and Tomcat For Spring and Angular App

I have Spring boot and Angular app in Tomcat Container deployed on Server. It works totally fine on localhost.

Now i am trying to map my domain with the application.

when i call my domain then api calls from Angular to Spring are not getting executed. Since they are on same server i am using localhost to call the api's from angular to spring. which works on my server browser itself but not somewhere else which is clear to me why its not working.

but i am not totally sure how to go around it. response

here is my nginx configuration

   server {
        listen       80;
        server_name localhost mydomain mydomain;


        #access_log  logs/host.access.log  main;

        location {
            root   html;
         proxy_pass      http://mydomain:8080;
            index  index.html index.htm;
        }       
    }
Tomcat configuration :

 <Host name="mydomain"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <Alias>mydomain</Alias>
        <Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />   
</Host>

My questions are :

Should i use the Server IP while calling the API's from Angular to Spring ? will it work ?

Second question is when i call my domain it redirects to tomcat manager page. I want it to go to localhost:8080/myApp. I tried proxy_pass as http://mydomain:8080/myapp & http://localhost:8080/myapp but still no success.

Any pointers for both of these questions would be highly appreciated. For any information i am available here.

Thankss

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Yes, you'd need to use server IP while calling the API. The reason for that being when the client requests your Angular website, the code is rendered on his website. Now when the angular website initiates an API call, it tries to hit ip localhost which means local with respect to the client browser, which is not the case as you meant local with respect to the Angular website.

With regards to your second question, you want to hit your domain and need your website to be loaded by the root path, right?

over 4 years ago · Santiago Trujillo Report

0

If you want to redirect to /web mapping when a user hits 'mydomain.com', you can add configuration like the following to your nginx:

server {
    listen 8080;

    location / {
        proxy_pass mydomain.com/web;
    } 
}

This will be listening to port 8080 and directing/appending all the requests to /web

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!