Welcome! Log In Create A New Profile

Advanced

problems with upstream

Posted by lopar 
problems with upstream
April 20, 2016 03:59AM
I try to use upstream and proxy for load balancing on CentOS 7 Minimal, but something is wrong. I use this manual: http://nginx.org/en/docs/http/load_balancing.html. When I open Nginx localhost in browser, it tells me, that «Site is temporarily unavailable» and writes this strings in error log:

2016/04/13 18:36:59 [crit] 5427#0: *20 connect() to 192.168.1.240:8080 failed (13: Permission denied) while connecting to upstream, client: 192.168.1.15, server: _, request: "GET / HTTP/1.1", upstream: "http://192.168.1.240:8080/", host: "192.168.1.135"
2016/04/13 18:36:59 [crit] 5427#0: *20 connect() to 192.168.1.237:8080 failed (13: Permission denied) while connecting to upstream, client: 192.168.1.15, server: _, request: "GET / HTTP/1.1", upstream: "http://192.168.1.237:8080/", host: "192.168.1.135"

Someone adviced me to turn off SElinux and see what I'll get. But when turned it off, I go to [upstream name] link, not the [upstream server].

I mean, when i use:

upstream sites { server 192.168.1.237:8080; }

location / { proxy_pass http://sites; }


I point my browser to http://localhost, and nginx redirects me to http://sites:8080, instead of http://192.168.1.1:8080.

I can't understand what's wrong, the manual said everything should work.
Help, please.
Attachments:
open | download - nginx.conf (551 bytes)
Re: problems with upstream
April 21, 2016 06:27AM
Working config part:

location / {
proxy_pass http://sites;
proxy_redirect http://192.168.1.135:8080 http://192.168.1.135;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

If problems with SELinux won't dissapear you need to turn httpd_can_network_connect directive on:

# sudo setsebool httpd_can_network_connect on -P
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 107
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready