AppBeat.io Blog

Uptime and performance monitoring made easy

AppBeat web app can now run on Linux!

We have successfully migrated our web application from .NET Core RC1 to .NET Core RC2 and published it on test Linux instance (CentOS). Best of all: AppBeat binaries are 100% identical to those on Windows (same cross platform codebase!) and were simply copied to Linux... And it works! It works great!

Here are some setup details for those who are interested.

First, you have to install .NET Core runtime by following simple instructions on Microsoft .NET Core website.

ASP.NET Core web applications are running on lightweight web server called Kestrel, but since it lacks some of important web server features (for example HTTPS, various built-in tools, ...) it is usually configured to run in tandem with other web server of your choice. On Windows this is IIS, on CentOS we selected NGINX. Those web servers then forward your request to Kestrel which runs your ASP.NET Core web application, creates output and returns it back to main web server.

To setup NGINX to forward requests to Kestrel you have to edit nginx.conf with following (adapt if needed):

location / 
{
proxy_pass http://127.0.0.1:5000;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Original-Proto $scheme;
proxy_set_header X-Original-For $remote_addr;
proxy_http_version 1.1;
}

Then we installed supervisor to monitor our Kestrel process and make sure it is always running:
sudo yum install supervisor

We created kestrel_default.ini file in /etc/supervisord.d/kestrel_default.ini with following content:

[program:kestrel_default]
command=dotnet /usr/share/nginx/WebApp/AppBeat.Web.dll
directory=/usr/share/nginx/WebApp
autorestart=true
autostart=true
stdout_logfile=/var/log/AppBeat/app_std_out.log
stderr_logfile=/var/log/AppBeat/app_err.log

After you saved file you can start Kestrel process by typing:

sudo supervisorctl start kestrel_default

Make sure nginx and supervisor are started on system boot:

sudo systemctl enable nginx
sudo systemctl enable supervisord

This is pretty much it :) We are now prepared for future! If you have questions you can reach us on @AppBeatMonitor

Comments are closed