<div dir="ltr">Hi, Josef<div><br></div><div>This what I get when trying to start NGINX with the simplified file.<br></div><div><br></div><div>[root@proxy conf.d]# cat webgateway.conf<br>upstream webgateway {<br>   server <a href="http://192.168.239.151:9090">192.168.239.151:9090</a>;<br>   server <a href="http://192.168.239.152:9090">192.168.239.152:9090</a>;<br>}<br><br>server {<br>   listen 9191;<br>   proxy_pass webgateway;<br>  }<br>}<br>[root@proxy conf.d]# nginx -t<br>nginx: [emerg] "proxy_pass" directive is not allowed here in /etc/nginx/conf.d/webgateway.conf:8<br>nginx: configuration file /etc/nginx/nginx.conf test failed<br>[root@proxy conf.d]# systemctl status nginx<br>● nginx.service - The nginx HTTP and reverse proxy server<br>   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)<br>   Active: failed (Result: exit-code) since Tue 2022-02-15 02:38:56 -03; 39s ago<br>  Process: 14415 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)<br>  Process: 14700 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)<br>  Process: 14699 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)<br> Main PID: 14417 (code=exited, status=0/SUCCESS)<br><br>Feb 15 02:38:56 proxy.lab.local systemd[1]: Starting The nginx HTTP and reverse proxy server...<br>Feb 15 02:38:56 proxy.lab.local nginx[14700]: nginx: [emerg] "proxy_pass" directive is not allowed here in /etc/nginx/conf.d/webgateway.conf:8<br>Feb 15 02:38:56 proxy.lab.local nginx[14700]: nginx: configuration file /etc/nginx/nginx.conf test failed<br>Feb 15 02:38:56 proxy.lab.local systemd[1]: nginx.service: control process exited, code=exited status=1<br>Feb 15 02:38:56 proxy.lab.local systemd[1]: Failed to start The nginx HTTP and reverse proxy server.<br>Feb 15 02:38:56 proxy.lab.local systemd[1]: Unit nginx.service entered failed state.<br>Feb 15 02:38:56 proxy.lab.local systemd[1]: nginx.service failed.<br>[root@proxy conf.d]#<br></div><div><br></div><div><br></div><div>Thank You!</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Em ter., 15 de fev. de 2022 às 12:25, Josef Vybíhal <<a href="mailto:josef.vybihal@gmail.com">josef.vybihal@gmail.com</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Seems to me, that you are not using stream{} module as noted by<br>
Francis, and you are still putting server block to http{}. If not,<br>
post nginx -T<br>
J.<br>
<br>
On Tue, Feb 15, 2022 at 4:17 PM Carlos Renato <<a href="mailto:crenatovb@gmail.com" target="_blank">crenatovb@gmail.com</a>> wrote:<br>
><br>
> Hi Francis,<br>
> Thanks for the reply and willingness to help me.<br>
><br>
> [root@proxy conf.d]# cat teste.conf<br>
> upstream webgateway {<br>
>     server <a href="http://192.168.239.151:9090" rel="noreferrer" target="_blank">192.168.239.151:9090</a>;<br>
>     server <a href="http://192.168.239.152:9090" rel="noreferrer" target="_blank">192.168.239.152:9090</a>;<br>
> }<br>
><br>
> server {<br>
>     listen 9191;<br>
>     proxy_pass webgateway;<br>
> }<br>
> [root@proxy conf.d]#<br>
><br>
> I cannot start NGINX.<br>
><br>
> Feb 15 01:56:24 proxy.lab.local systemd[1]: Starting The nginx HTTP and reverse proxy server...<br>
> 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<br>
> Feb 15 01:56:24 proxy.lab.local nginx[12274]: nginx: configuration file /etc/nginx/nginx.conf test failed<br>
> Feb 15 01:56:24 proxy.lab.local systemd[1]: nginx.service: control process exited, code=exited status=1<br>
> Feb 15 01:56:24 proxy.lab.local systemd[1]: Failed to start The nginx HTTP and reverse proxy server.<br>
> Feb 15 01:56:24 proxy.lab.local systemd[1]: Unit nginx.service entered failed state.<br>
> Feb 15 01:56:24 proxy.lab.local systemd[1]: nginx.service failed.<br>
><br>
> I can only start NGINX if the file is as below.<br>
><br>
> upstream webgateway {<br>
>    server <a href="http://192.168.239.151:9090" rel="noreferrer" target="_blank">192.168.239.151:9090</a>;<br>
>    server <a href="http://192.168.239.152:9090" rel="noreferrer" target="_blank">192.168.239.152:9090</a>;<br>
> }<br>
><br>
> server {<br>
>    listen 9191;<br>
><br>
>    location / {<br>
>          proxy_set_header Host $host;<br>
>          proxy_set_header X-Real-IP $remote_addr;<br>
>          proxy_pass <a href="http://webgateway" rel="noreferrer" target="_blank">http://webgateway</a>;<br>
>   }<br>
> }<br>
><br>
> The behavior on the client is the same.<br>
> I can load HTTP page and cannot HTTPS. On the Web Gateway, I view the access logs with the client's IP.<br>
><br>
> In tests, I noticed that the "http_pass" below the "listen", I can't start NGINX.<br>
> I had to also put it as "http" or <a href="http://webgateway" rel="noreferrer" target="_blank">http://webgateway</a>;<br>
><br>
> If you don't put the parameters below, the proxy tries to load the page <a href="http://webgateway" rel="noreferrer" target="_blank">http://webgateway</a>.<br>
> proxy_set_header Host $host;<br>
><br>
> The parameter below registers the IP-Real of the client in the proxy.<br>
> proxy_set_header X-Real-IP $remote_addr;<br>
><br>
> Any tips? Thank You.<br>
><br>
><br>
><br>
> Em ter., 15 de fev. de 2022 às 11:16, Francis Daly <<a href="mailto:francis@daoine.org" target="_blank">francis@daoine.org</a>> escreveu:<br>
>><br>
>> On Tue, Feb 15, 2022 at 10:29:50AM -0300, Carlos Renato wrote:<br>
>><br>
>> Hi there,<br>
>><br>
>> > My file is like this.<br>
>><br>
>> Untested by me, but I have edited this to now resemble what I think<br>
>> you want...<br>
>><br>
>> > upstream webgateway {<br>
>> >    server <a href="http://192.168.239.151:9090" rel="noreferrer" target="_blank">192.168.239.151:9090</a>;<br>
>> >    server <a href="http://192.168.239.152:9090" rel="noreferrer" target="_blank">192.168.239.152:9090</a>;<br>
>> > }<br>
>> ><br>
>> > server {<br>
>> >    listen 9191;<br>
>> >    proxy_pass webgateway;<br>
>> > }<br>
>><br>
>> ...that is, keep your upstream{} but remove the keepalive; adjust your<br>
>> server{} to just have "listen" and a different "proxy_pass"; and put<br>
>> the whole thing inside "stream{}" not "http{}".<br>
>><br>
>> > I'm able to open HTTP requests in the client's browser.<br>
>> > The problem is being the HTTPS requests.<br>
>> > Is there any way for NGINX to receive the traffic and forward it (balanced)<br>
>> > to the proxy servers?<br>
>> > A simpler way. That way I could include the Web Gateway certificate in the<br>
>> > Windows client.<br>
>><br>
>> If I have understood correctly what you are trying to do, the notes at<br>
>> <a href="https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/" rel="noreferrer" target="_blank">https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/</a><br>
>> look relevant. That expands on what is at<br>
>> <a href="http://nginx.org/en/docs/stream/ngx_stream_core_module.html" rel="noreferrer" target="_blank">http://nginx.org/en/docs/stream/ngx_stream_core_module.html</a>.<br>
>><br>
>> Cheers,<br>
>><br>
>>         f<br>
>> --<br>
>> Francis Daly        <a href="mailto:francis@daoine.org" target="_blank">francis@daoine.org</a><br>
>> _______________________________________________<br>
>> nginx mailing list -- <a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
>> To unsubscribe send an email to <a href="mailto:nginx-leave@nginx.org" target="_blank">nginx-leave@nginx.org</a><br>
><br>
><br>
><br>
> --<br>
><br>
><br>
> _______________________________________________<br>
> nginx mailing list -- <a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
> To unsubscribe send an email to <a href="mailto:nginx-leave@nginx.org" target="_blank">nginx-leave@nginx.org</a><br>
_______________________________________________<br>
nginx mailing list -- <a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
To unsubscribe send an email to <a href="mailto:nginx-leave@nginx.org" target="_blank">nginx-leave@nginx.org</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"> <br><br></div>