珍尔姿,quickdo官网,anklepants
kestrel 非常适合从 asp.net core 提供动态内容。 但是,web 服务功能不像服务器(如 iis、apache 或 nginx)那样功能丰富。 反向代理服务器可以从 http 服务器卸载服务静态内容、缓存请求、压缩请求和 ssl 终端等工作。 反向代理服务器可能驻留在专用计算机上,也可能与 http 服务器一起部署。
鉴于此指南的目的,使用 nginx 的单个实例。 它与 http 服务器一起运行在同一服务器上。
执行 dotnet --info,验证安装结果,如下:
.net core sdk (reflecting any global.json):
version: 2.1.401
commit: 91b1c13032
runtime environment:
os name: centos
os version: 7
os platform: linux
rid: centos.7-x64
base path: /usr/share/dotnet/sdk/2.1.401/
...
发布linux程序 dotnet publish -c release -o "xx:\web_iis\mvcapp2" -r centos.7-x64
检查站点运行情况 curl
查看防火墙状态 firewall-cmd --state //running 表示运行
附防火墙相关命令
启动: systemctl start firewalld
查看状态:systemctl status firewalld
停止:systemctl disable firewalld
禁用:systemctl stop firewalld
启动服务:systemctl start firewalld.service
关闭服务:systemctl stop firewalld.service
重启服务:systemctl restart firewalld.service
服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed
查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息: firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic
安装nginx
命令 curl -o nginx.rpm
rpm -ivh nginx.rpm
yum install nginx
启动 nginx
命令:systemctl start nginx
设置开机启动 systemctl enable nginx
firewall-cmd --zone=public --add-port=80/tcp --permanent(永久启用80端口)
重启防火墙 systemctl restart firewalld
浏览器测试nginx能否正常访问
修改nginx配置文件
yum -y install vim 可用默认vi替代
修改 /etc/nginx/conf.d/default.conf 文件。
通过 vim /etc/nginx/conf.d/default.conf 打开,编辑里面的内容,保存时按 esc 再输入 :wq! 命令保存退出
修改为如下脚本:
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; } }
nginx参考文献
其他参考文档:
配置守护服务(supervisor)
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
linux下文本编辑器vim的使用方法(复制、粘贴、替换、行号、撤销、多文件操作)
网友评论