配置dotnet+nginx+SSL+centos
在centos 8上配置dotnet和nginx,并支持SSL,nginx配置请到我的资源里下载:
1、yum update -y
2、dnf install dotnet-sdk-3.1 -y
3、dnf install nginx -y
4、
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --reload
5、
cd /etc/systemd/system
vim zhcl.service
内容如下:
[Unit]
Description=ZHCL
[Service]
WorkingDirectory=/var/dotnetwww/zhclapi
ExecStart=/usr/bin/dotnet /var/dotnetwww/zhclapi/ZhclService.dll
Restart=always
RestartSec=10
SyslogIdentifier=ZHCL
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
6、复制域名证书到/etc/nginx/cert (cert目录自己创建)
7、复制nginx.conf到/etc/nginx目录覆盖
8、
nginx -c /etc/nginx/nginx.conf
nginx -s reload
systemctl restart zhcl.service
9、修改selinux对nginx的屏蔽
cd /var/log/audit
setsebool -P httpd_can_network_connect 1
ausearch -c ‘nginx’ --raw | audit2allow -M my-nginx
semodule -i my-nginx.pp
10、可以设置这些服务自动启动
systemctl enable nginx
systemctl enable zhcl.service
11、设置外部防火墙端口