Environment: ASP.NET Core 2.1 under Ubuntu 18.04
By default, a newly created asp.net core app runs at http://localhost:5000 and automatically redirects to https://localhost:5001
As I intend to run my app under nginx (and use SSL capabilities of nginx), I would like to run my released app without https and at a specific port, say, 6000.
Post ASP.NET Core 2.1 + Kestrel (How to disable HTTPS) explains that one has to simply use "--urls" argument to achieve this.
Here is what I tried:
$ dotnet publish --configuration Release
$ dotnet bin/Release/netcoreapp2.1/MyApp.dll
The app now starts listening at http://localhost:5000 and https://localhost:5001. When I browse to http://localhost:5000, it automatically redirects to https://localhost:5001. So far so good.
Now, I try running at port 6000:
$ dotnet bin/Release/netcoreapp2.1/MyApp.dll
--urls="http://localhost:6000"
From the messages in the terminal window, the app seems to start listening at http://localhost:6000. However, browsing to this url results in "this site can't be reached" error.
I even tried:
$ dotnet bin/Release/netcoreapp2.1/MyApp.dll
--urls="http://localhost:6000,https://localhost:6001"
In this case, I get an error that "a path base can only be configured using IApplicationBuilder.UsePathBase()."
Can someone please tell me how I can simply run an application at a specified port? I am hoping I don't need to hard-code port numbers.