0

can you help on the nginx configration .

my application on node express js I have two application express js i want to run in single domain.

This my server like : app.example.com

app1 run  :- app.example.com/allinone/
app2 run  :-app.example.com/app/

I am using the express redirect based on the root URL redirect.

res.redirect('/login')

this response redirects to the root server domain URL I want that to redirect to the location URL.

here my nginx server block code

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

     server_name app.example.com;
location /allinone/ {
  proxy_set_header Host $host;
  proxy_redirect ~/(.*)$ /allinone/$1;
  proxy_pass http://127.0.0.1:5002;
}

location /app/ {
  proxy_set_header Host $host;
  proxy_redirect ~/(.*)$ /app/$1;
  proxy_pass http://127.0.0.1:5000;
}
}

app is working with the location host when i move to production with sub url it was not working.

I have also tried those solutions.

Express.js redirect with virtual path

 proxy_set_header Host $host;
#replase with 
proxy_set_header Host $http_host;

Express.js redirect with virtual path Nginx is redirecting proxy_pass to root path automatically

Error

This page isn’t working app.example.com redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS

I have tried a new clean browser but still have the same Error.

but direct open api GET endpoint /allinone/openapi not working.

Sanjay
  • 1
  • 2

0 Answers0