Welcome! Log In Create A New Profile

Advanced

Using a variable in PROXY_PASS

Posted by Tyler_durden_83 
Using a variable in PROXY_PASS
February 28, 2018 10:10AM
Dear friends,
I'll go straight to the point. This is my nginx.conf:

set $upstream_portainer "http://my_portainer-service:9000";

location /portainer/ {
proxy_http_version 1.1;
proxy_set_header Host $http_host; # required for docker client's sake
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 900;

proxy_set_header Connection "";
proxy_buffers 32 4k;
#proxy_pass http://my_portainer-service:9000/; # --> this WORKS
#proxy_pass $upstream_portainer/; # --> this does NOT work
proxy_pass ${upstream_portainer}/; # --> this does NOT work
}

Why doesn't it work with the alias? I'm sure I have seen it used many times, especially in conunction with Docker service names, so that they'd be reevaluated periodically rather than just at startup of NGINX.

Thank you so much,
Best regards,
Roberto
Re: Using a variable in PROXY_PASS
March 02, 2018 02:09AM
Hi Tyler_durden_83;


I think you should remove the last slash of the prox_pass parameters.I mean, you could try this 'proxy_pass $upstream_portainer' and 'set $upstream_portainer "http://my_portainer-service:9000/"; ' .

Please inform us if it works.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 166
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