Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to deploy. Net core sites in nginx

Shulou Source: shulou.com Published: 2022-06-01 20:57:07 11月08日 Update

Today, I will talk to you about how to deploy the .net core site in nginx. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.

Steps

The aspnetcore program port number 5001, the actual external port number 8001, is equivalent to forwarding the request received by 8001 to 5001.

Throw out all the published files and go inside / var/www/JuXiangTou. You can use the scp command or winscp client

Centos 7.x

The running environment of aspnet core does not need to be installed with sdk. Generally speaking, sdk contains runtime.

Yum install libunwind libicuyum install aspnetcore-runtime-2.1

Nginx, a reverse proxy service, forwards incoming http requests to the actual aspnetcore processing

Sudo yum install epel-releasesudo yum install nginxsudo systemctl start nginxsudo systemctl enable nginx

Install the nginx to configure the port and so on.

Cd / etc/nginx/

Nginx.conf is the default configuration file and is basically untouched.

Cd conf.dvim kestrel-juxiangtou.conf

The following is mainly that the two port numbers need to be changed, and the rest can not be changed.

Server {listen 8001; location / {proxy_pass http://localhost:5001; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $http_host; proxy_cache_bypass $http_upgrade;}}

Save exit

Verify the configuration, and then reload

Sudo nginx-t sudo nginx-s reload

Firewall firewall-cmd. It doesn't have to be installed, it depends on the environment.

Systemctl status firewalldfirewall-cmd-zone=public-add-port=8001/tcp-permanentfirewall-cmd-reloadsystemctl restart firewalld.service

Build a service to maintain the program process of dotnetcore

Cd / etc/systemd/systemvim kestrel- juxiangtou.service[Unit] Description= JuXiangTou[Service] WorkingDirectory=/var/www/JuXiangTouExecStart=/usr/bin/dotnet / var/www/JuXiangTou/Site.WebApi.dllRestart=alwaysRestartSec=10SyslogIdentifier=JuXiangTouUser=rootEnvironment=ASPNETCORE_ENVIRONMENT= Production[Install] WantedBy=multi-user.target

Save exit

After reading the above content in systemctl restart kestrel-juxiangtou.service, do you have any further understanding of how to deploy a. Net core site in nginx? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Content slogan configuration site no actual file environment program service two proxy service command client client that is more steps knowledge port Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology Xiaomi Redmi vpn