Why i can't use variable $user in proxy_pass - like in example below?
server {
listen 80;
server_name ~^(?P<user>[a-z|A-Z|0-9|_|-]+)\.example\.net$;
root /home/$user/webapps/;
location /app/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unix:/home/$user/webapps/app/run/gunicorn.sock:/;
}
}
Is this possible to achieve or should i give up?
And this one would be perfect, but it is also not working.
server {
listen 80;
server_name ~^(?P<user>[a-z|A-Z|0-9|_|-]+)\.example\.net$;
root /home/$user/webapps/;
location ~ ^\/(?P<app>[\w-_]+)(\/.*)?$ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unix:/home/$user/webapps/$app/run/gunicorn.sock:/;
}
}
I read this and that and here but none of them cover proxy_pass through unix socket.
The proxy pass directives don't see $user and $app as parameter in your case you have to tell him via the
$is_args
and$args
variables like so:Found that 'uri' was the problem not variables, so the correct config should be
i should turn on debugging faster, thank you for support.
I can't check this solution anymore, this is my guess right now - because i went with one conf per app, i will try to unify my config later.