Linux CentOS 7 下dotnet core webpai + nginx 部署

参考:https://www.jianshu.com/p/b1f573ca50c7

跟着做到,配置nginx访问dotnet core网站时,报错了。

错误如下所示——

 查看nginx的错误日志: cat /var/log/nginx/error.log | more

 再查看系统的nginx相关的审计日志 cat /var/log/audit/audit.log | grep nginx | grep denied

 bing查找关键字——.netcore webapi nginx permission denied

stackoverflow上找到了可用信息:https://stackoverflow.com/questions/36315637/permission-denied-connecting-to-upstream

终于找到了问题的原因:SELinux

在官网找到了更加详细的描述:

RHEL和CentOS类的服务器,SELinux默认时开启的。

接着下面还有一段描述:

SELinux在RHEL和CentOS系统中,默认的标签是httpd_t,这个安全程序会阻止location代理(英语水平比较烂,大概的意思就是这样)

官网给出了临时关闭SELinux的指令【# semanage permissive -a httpd_t】

当关闭后,再在宿主机上进行访问,发现正常了。

还要注意的是.net core webapi 默认开了https的访问方式,需要在nginx代理中配置这个https的访问地址,否则还是无法访问成功。

 下面是我的nginx.conf配置

 当然了,这个SELinux还要不能关闭的,根据官网的说明进行相应的配置即可,这里不多说了。

资源:

https://www.nginx.com/blog/using-nginx-plus-with-selinux/

https://www.jianshu.com/p/b1f573ca50c7

(完)

原文地址:https://www.cnblogs.com/lishidefengchen/p/11447343.html