NGINX load balancing - Proxy

Carlos Renato crenatovb at gmail.com
Tue Feb 15 15:13:28 UTC 2022


Hi Francis,
Thanks for the reply and willingness to help me.

[root at proxy conf.d]# cat teste.conf
upstream webgateway {
    server 192.168.239.151:9090;
    server 192.168.239.152:9090;
}

server {
    listen 9191;
    proxy_pass webgateway;
}
[root at proxy conf.d]#

I cannot start NGINX.

Feb 15 01:56:24 proxy.lab.local systemd[1]: Starting The nginx HTTP and
reverse proxy server...
Feb 15 01:56:24 proxy.lab.local nginx[12274]: nginx: [emerg] "proxy_pass"
directive is not allowed here in /etc/nginx/conf.d/teste.conf:8
Feb 15 01:56:24 proxy.lab.local nginx[12274]: nginx: configuration file
/etc/nginx/nginx.conf test failed
Feb 15 01:56:24 proxy.lab.local systemd[1]: nginx.service: control process
exited, code=exited status=1
Feb 15 01:56:24 proxy.lab.local systemd[1]: Failed to start The nginx HTTP
and reverse proxy server.
Feb 15 01:56:24 proxy.lab.local systemd[1]: Unit nginx.service entered
failed state.
Feb 15 01:56:24 proxy.lab.local systemd[1]: nginx.service failed.

I can only start NGINX if the file is as below.

upstream webgateway {
   server 192.168.239.151:9090;
   server 192.168.239.152:9090;
}

server {
   listen 9191;

   location / {
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_pass http://webgateway;
  }
}

The behavior on the client is the same.
I can load HTTP page and cannot HTTPS. On the Web Gateway, I view the
access logs with the client's IP.

In tests, I noticed that the "http_pass" below the "listen", I can't start
NGINX.
I had to also put it as "http" or http://webgateway;

If you don't put the parameters below, the proxy tries to load the page
http://webgateway.
proxy_set_header Host $host;

The parameter below registers the IP-Real of the client in the proxy.
proxy_set_header X-Real-IP $remote_addr;

Any tips? Thank You.



Em ter., 15 de fev. de 2022 às 11:16, Francis Daly <francis at daoine.org>
escreveu:

> On Tue, Feb 15, 2022 at 10:29:50AM -0300, Carlos Renato wrote:
>
> Hi there,
>
> > My file is like this.
>
> Untested by me, but I have edited this to now resemble what I think
> you want...
>
> > upstream webgateway {
> >    server 192.168.239.151:9090;
> >    server 192.168.239.152:9090;
> > }
> >
> > server {
> >    listen 9191;
> >    proxy_pass webgateway;
> > }
>
> ...that is, keep your upstream{} but remove the keepalive; adjust your
> server{} to just have "listen" and a different "proxy_pass"; and put
> the whole thing inside "stream{}" not "http{}".
>
> > I'm able to open HTTP requests in the client's browser.
> > The problem is being the HTTPS requests.
> > Is there any way for NGINX to receive the traffic and forward it
> (balanced)
> > to the proxy servers?
> > A simpler way. That way I could include the Web Gateway certificate in
> the
> > Windows client.
>
> If I have understood correctly what you are trying to do, the notes at
>
> https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/
> look relevant. That expands on what is at
> http://nginx.org/en/docs/stream/ngx_stream_core_module.html.
>
> Cheers,
>
>         f
> --
> Francis Daly        francis at daoine.org
> _______________________________________________
> nginx mailing list -- nginx at nginx.org
> To unsubscribe send an email to nginx-leave at nginx.org
>


--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20220215/ec5226ba/attachment.htm>


More information about the nginx mailing list