nginx deploys the method of the.net core site
- 2020-05-15 03:33:16
- OfStack
steps
The aspnetcore program port number 5001 and the actual external port number 8001 are equivalent to forwarding the request received by 8001 to 5001.
Throw away all the published files /var/www/JuXiangTou. You can use the scp command or the winscp client
yum install libunwind libicu
yum install aspnetcore-runtime-2.1
nginx, a reverse proxy service, forwards incoming http requests to the actual aspnetcore for processing
sudo yum install epel-release
sudo yum install nginx
sudo systemctl start nginx
sudo systemctl enable nginx
To install nginx you need to configure a port or something.
cd /etc/nginx/
nginx.conf is the default configuration file and is largely untouched.
cd conf.d
vim kestrel-juxiangtou.conf
The following is the need to change the two port Numbers 1, the rest can be unchanged.
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 the exit
Verify the 1 configuration and then reload
sudo nginx -t
sudo nginx -s reload
Firewall firewall-cmd. Not 1 fixed installed, to see the environment.
systemctl status firewalld
firewall-cmd --zone=public --add-port=8001/tcp --permanent
firewall-cmd --reload
systemctl restart firewalld.service
Build a service to maintain the dotnetcore process
cd /etc/systemd/system
vim kestrel-juxiangtou.service
[Unit]
Description=JuXiangTou
[Service]
WorkingDirectory=/var/www/JuXiangTou
ExecStart=/usr/bin/dotnet /var/www/JuXiangTou/Site.WebApi.dll
Restart=always
RestartSec=10
SyslogIdentifier=JuXiangTou
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
Save the exit
systemctl restart kestrel-juxiangtou.service
Restart the service 1 time.
Configure 1 port in the network security group of aliyun
The resources
http://www.projectcodify.com/hosting-aspnet-core-on-linux-using-nginx