12
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

CentOS7のnginxでポートフォワードできない時

CentOS7でポートフォワードしようとしたらちょっとハマったのでメモ。

下記のように設定したNginxを動かした

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

location / {
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $http_host;
}
}

するとこんなエラーが出ましたよと。

2015/12/25 00:00:00 [crit] 6797#0: *1 connect() to 127.0.0.1:8080 failed (13: Permission denied) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: _, request: "GET /login HTTP/1.1", upstream: "http://127.0.0.1:8080/login", host: "xxx.xxx.xxx.xxx"

これはSELinuxのBool値の問題のようで、次のコマンドをうったら解決できました。

$ setsebool httpd_can_network_connect on -P
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
12
Help us understand the problem. What are the problem?