❔ Why can't I host my ASP.NET WebAPI on Ubuntu ?
1) I made a new user
sudo adduser aspsites
2) I created a folder called surf
and cloned my repo inside it git clone myurl
(now the full path is: /home/aspsites/surf/SurfFinder/SurfFinderAPI/SurfFinderAPI.csproj
)
3) Ran dotnet build
(all good)
4) Added the following configuration file in /etc/nginx/sites-enabled/aspsites
:
5) Ran dotnet run
and then the CLI got stuck? Now I can't run any command.
And of course, when I visit www.mywebsite.com/surf/SurfFinder/WeatherForecast
nothing happens 🤔.
I'm sure I'm doing a bunch of things wrong. I am completely new to Linux & ASP.NET, but I'm willing to learn, so please help me if you can.9 Replies
the port is 5088 no ?
Thanks, I changed it.
Now I'm getting this issue
Plus this in the terminal:
This is my /aspsites/ file:
I assume you already got yourself a URL.
Yes
Probs because it's sending the complete path to the proxy
/surf/SurfFinder/WeatherForecast
instead of /WeatherForecast
You can fix this by adding a /
to the proxy pass URL: proxy_pass https://localhost:5088/;
from what I found.
https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_passyeah i had that path issue as well
Works perfectly, thanks.
Is it possible to run another API now on the same Nginx server? For example, both /surf/SurfFinder/ and /surf/Football/ simultaneously. And if so, is there any way to automate the process so I don't have to modify
sites-enabled
each time I upload an ASP.NET project in a different folder? @gerard
Also, when I close my Putty terminal, the API is no longer running 🤔 ?Yes, if you give the other ASP.NET Core application a different port you can map that to Nginx.
I'm not sure if there is already a way to automate this (since I'm not using Nginx myself).
That's because you probs started the ASP.NET Core process in your session. If you disconnect, your session gets closed; and so does the ASP.NET Core server.
Again, I'm not a Linux pro but from my knowledge you have the following options:
1. Use
screen
to start the process.
If you detach from the virtual screen/session the process keeps running.
This is the easiest, but if your server ever restarts you have to start everything manually yourself. So not really recommended.
2. Make a service
No clue what distro you're using, but there are docs about systemd
here:
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-7.0#create-the-service-file
3. Run it in DockerWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.