LoginSignup
11
12

More than 5 years have passed since last update.

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

Posted at

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
11
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
12