使用Tarantool http作为Nginx上游服务器-得到错​​误13:权限被拒绝

问题描述

拥有Nginx yum安装Nginx

拥有Tarantool +弹药筒

Nginx.conf

upstream tarantool_httpd {
server 172.16.72.18:8082 max_fails=1 fail_timeout=15s;
keepalive 32;   
}

  server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/Nginx/html;

        # Load configuration files for the default server block.
        include /etc/Nginx/default.d/*.conf;


        location / {
        }

    location = /redirections
    {
        proxy_pass http://tarantool_httpd;
    }
    location = /admin
    {
        proxy_pass http://tarantool_httpd;
    }


        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }

当我请求URL http://172.16.72.18/admin时,access.log中出现错误502,而Nginx error.log中出现了错误

connect() to 172.16.72.18:8082 Failed (13: Permission denied) while connecting to upstream,client: 172.16.72.32

解决方法

它似乎已启用SELinux。

使用sestatus进行检查,并使用sudo setenforce 0暂时禁用

如果问题得以解决,则可以通过编辑/etc/selinux/config并将SELINUX设置为disabled来永久禁用它

,

如果您不想完全禁用SELinux(除非您真的确实需要这样做,否则我不建议这样做),使用此命令应该足以允许nginx连接到后端:

sudo setsebool -P httpd_can_network_connect on

但是您可能会遇到其他一些SELinux不兼容的问题,因此在遇到任何问题之前先检查sudo setenforce 0是否已经解决了一些奇怪的问题是很有意义的。