aspnetcore: Kestrel does not listen for https when run as a service on Ubuntu
I am trying to host an ASP.Net Core MVC application (https redirection is enabled) on Ubuntu server, using Nginx as a reverse proxy. I have created and installed a local SSL certificate using OpenSSL. When i run my application using dotnet CLI it listens on both http://localhost:5000 & https://localhost:5001, and i am able to access it on web using https (http requests are being redirect to https by Nginx).
The problem is when i try to run the as a service, it only listens on http://localhost:5000.
Here’s the *.service file :
[Unit]
Description=Test ASP.Net core web application service.
[Service]
WorkingDirectory=/home/ubuntu/MyAppFolder
ExecStart=/usr/bin/dotnet/home/ubuntu/MyAppFolder/MyApplication.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
SyslogIdentifier=MyApplication
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Development
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
Environment=ASPNETCORE_HTTPS_PORT=5001
Environment=ASPNETCORE_URLS=http://localhost:5000;https://localhost:5001
[Install]
WantedBy=multi-user.target
Environment details : ASP.Net Core 2.1.1, ASP.Net Core SDK 2.1.3, Nginx 1.14, Ubuntu 16.04
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 36 (16 by maintainers)
@Praveen-Rai, I’ve been struggling with this issue for two days. Thank you so much for your Stack-Overflow solution. I’ll be trying it this afternoon.
@javiercn - I’m a little lost in the haze of others coming in and out of the discussion, so I’m not sure if you are the best contact for this, but I think it’s worth pointing out that using a service to launch the app is outlined in the MS Doc: Host ASP.NET Core on Linux with Nginx. This seems like a great place to either add the points @Praveen-Rai has raised or just to remove entirely.
@danroth27 , @Tratcher Any updates on the Kestrel error logging for End-Point configuration issues ?
@guardrex For sure … Meanwhile i’ll try to consolidate everything and get it ready for you. Also i request you to please follow this discussion and also any discussion on Docs repository related to Linux and SSL. Thanks.
@guardrex We must include the Kestrel endpoint configuration to :
Host ASP.NET Core on Linux with Nginx
Host ASP.NET Core on Linux with Apache
Nope. That’s normal.