Host ASP.NET Core on Linux with Nginx

Hisoka Morow

New Member
Joined
Nov 20, 2018
Messages
2
Reaction score
0
Credits
0
Hi! I'm new on liux.
I'm learning this tutorial https://docs.microsoft.com/en-US/as...x-nginx?tabs=aspnetcore2x&view=aspnetcore-2.1

I need Host my Web Application ASP.NET Core on my Linux CentOS with Nginx

I followed the steps but I have a problem status kestrel-helloapp.service is activating
why not complete active the service?


ERROR:"activating"
Code:
[root@CentOS /]# sudo systemctl status kestrel-helloapp.service
● kestrel-helloapp.service - Example .NET Web API App running on Ubuntu   Loaded: loaded (/etc/systemd/system/kestrel-helloapp.service; enabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Sun 2018-11-18 09:45:06 -04; 5s ago
  Process: 16742 ExecStart=/usr/bin/dotnet /usr/share/nginx/html/prueba.dll (code=exited, status=217/USER)
 Main PID: 16742 (code=exited, status=217/USER)

Nginz Test
Code:
[root@CentOS ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful


/etc/nginx/nginx.conf
Code:
worker_processes  1;
events {
    worker_connections  1024;
}


http {

    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
   
    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}



/etc/nginx/conf.d/default.conf
Code:
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
    listen 80;
    location / {
    proxy_pass http://localhost:5000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection keep-alive;
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    }
}

my app default root

/usr/share/nginx/html

here stay my AppNetCore.dll




/etc/nginx/proxy.conf
Code:
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 10m; 
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
/etc/systemd/system/kestrel-helloapp.service

[Unit]
Description=Example .NET Web API App running on Ubuntu

[Service]
WorkingDirectory=/usr/share/nginx/html
ExecStart=/usr/bin/dotnet /usr/share/nginx/html/prueba.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target
 

Members online


Top