HI all, I am setting up my first nginx server.
I have a REST API developed in .net core which has few methods in it. I am trying to use nginx as reverse proxy here. my api is running in this URL "http://localhost:5000/weatherforecast". similarly I have few other routes like "http://localhost:5000/hello" and "http://localhost:5000/test"..
here is a snippet from nginx.conf file.
-------------------------------------------------
upstream webapi {
server 127.0.0.1:5000;
}
server {
listen 7070;
server_name mysite1;
location ~* ^/myapi {
proxy_pass http://webapi;
}
}
------------------------------------------------------
From my browser when I hit the address "http://127.0.0.1:7070/myapi/weatherforecast", am getting "Page not found" exception.
But when I have the configuration as below it working fine (without upstream).
----------------------------------------
server {
listen 7070;
server_name mysite1;
location ~* ^/myapi {
proxy_pass http://127.0.0.1:5000/weatherforecast
}
}
-----------------------------------------------
Kindly suggest me how to make the routes (weatherforeacast, hello, test) to work. do I need to give separate location for each route.
Thanks,
Sanjay.
I have a REST API developed in .net core which has few methods in it. I am trying to use nginx as reverse proxy here. my api is running in this URL "http://localhost:5000/weatherforecast". similarly I have few other routes like "http://localhost:5000/hello" and "http://localhost:5000/test"..
here is a snippet from nginx.conf file.
-------------------------------------------------
upstream webapi {
server 127.0.0.1:5000;
}
server {
listen 7070;
server_name mysite1;
location ~* ^/myapi {
proxy_pass http://webapi;
}
}
------------------------------------------------------
From my browser when I hit the address "http://127.0.0.1:7070/myapi/weatherforecast", am getting "Page not found" exception.
But when I have the configuration as below it working fine (without upstream).
----------------------------------------
server {
listen 7070;
server_name mysite1;
location ~* ^/myapi {
proxy_pass http://127.0.0.1:5000/weatherforecast
}
}
-----------------------------------------------
Kindly suggest me how to make the routes (weatherforeacast, hello, test) to work. do I need to give separate location for each route.
Thanks,
Sanjay.