Score:0

configure nginx to use a proxy when connecting to upstream

fr flag

it's very hard to find something on google - you get too many results from nginx and proxy alone.

so we have a nginx-docker-container which delivers some static files and should talk to a backend-server on specific locations. we gave http_proxy and https_proxy per docker-compose into the environment of the container

trying the connection with curl results in success - its because of the http_proxy/https_proxy env

we tried without env and gave curl the proxy as param to reproduce the behaviour - so its important to use this proxy to talk to the upstream

here a part of the nginx-config

server {
    listen test.virtual:443 ssl http2;
    ...
    location /up {
        proxy_pass https://backend:12345
    }

when requesting https://test.virtual/up we get an error in nginx Log: connection refused

but curl can connect:

curl -k https://backend:12345

so how can i configure nginx to use this proxy too?

Score:0
lb flag

I had the same issue running with nginx on Centos, this is because you are trying to set a proxy-pass with a port different from custom ports 80 and 443. To solve this, you have to enable SElinux flag httpd_can_network_connect (diasbled by default) as described in nginx documentation => https://www.nginx.com/blog/using-nginx-plus-with-selinux/

setsebool -P httpd_can_network_connect 1

enabling this flag (httpd_can_network_connect) allows processes labeled with the httpd_t context (such as NGINX) to connect to all TCP socket types that have the port_type attribute

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.