During development I control the http and https ports using the launchSettings.json file as marked below:
Is it correct to use this same approach to control the kestrel port during deployment to production? Or do I need to make any port config in the appsettings.json or any other file?
CodePudding user response:
Because launchSettings.json
work for Development env Development and launchSettings.json
There are the several ways you can set the port in Kestrel endpoints for production environment
Specify URLs using the:
ASPNETCORE_URLS
environment variable.use
dotnet
with--urls
command-line argument.dotnet yourdll.dll --urls http:// :2222
UseUrls
extension method.urls
host configuration key.
If we want to set a Kestrel endpoint Follow the node to set the URL for your project appsettings.
Kestrel / EndPoints / Http / Url
{
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http:// :2222"
}
}
}
}
Note
But I would suggest you add Nginx
or Certbot
to be reverse proxy instead of setting port and expose to outside connection.