nginx代理服务器本地主机权限被拒绝 [英] nginx proxy server localhost permission denied

查看:250
本文介绍了nginx代理服务器本地主机权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是将nginx设置为直接代理tomcat应用服务器的Web服务器. 当用户连接到我的网站时,Nginx应该将请求重定向到运行Tomcat应用程序服务器的端口8080.

I am just setting up nginx as a webserver that proxies directly to a tomcat app server. When the user connects to my website Nginx should redirect the request to port 8080 where the tomcat app server is running.

我正在运行Redhat 7的Amazon ec2实例上做所有事情.

I am doing everything on amazon ec2 instance that is running Redhat 7.

到目前为止,我的情况是:

What I have so far is this:

nginx.conf file

user nginx;
worker_processes  1;

server {
 listen 80;
 server_name mydomainname;
 access_log  /var/log/nginx/example.log;
 error_log /var/log/nginx/example.error.log;

 location / {
  proxy_pass http://localhost:8080/example/;
 }
}

我得到的错误是 在连接到上游客户端时(13:权限被拒绝)

The error that I am getting is (13: Permission denied) while connecting to upstream, client

这绝对是用户访问问题,但似乎无法解决.似乎nginx没有访问重定向到端口8080的权限.

This is definitely a user access issue, but cannot seem to figure it out. It seems like nginx does not have access to redirect to port 8080.

此外,nginx在myuser下运行

Also, nginx is running under myuser

root     15736   nginx: master process   /usr/sbin/nginx
myuser  15996   nginx: worker process
root     16017   grep --color=auto nginx

我试图放127.0.0.1而不是localhost,但是没有运气. 我还尝试将nginx.conf中的用户更改为myuser,仍然没有运气. 当我直接连接到应用程序服务器时,我没有任何问题.

I have tried to put 127.0.0.1 instead of localhost, but no luck. I have also tried to change the user in the nginx.conf to myuser, still no luck. When I connect directly to the application sever I have no issues.

Example URL of my tomcat http://mydomain:8080/example/

先谢谢您.

推荐答案

经过2天的搜索,我终于找到了解决方案. SELinux不知何故不允许Nginx代理到我的服务器.运行以下命令可解决此问题.

I was able to find a solution after 2 days of searching. Somehow SELinux was not permitting Nginx to proxy to my server. Running the command below fixed the issue.

 /usr/sbin/setsebool httpd_can_network_connect true 

这篇关于nginx代理服务器本地主机权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆