I have multiple node websockets that are available through a url matching the UNIX socket paths. Instead of duplicating the location directive, I would like to have something like a list of Urls that will be used as socket name. Using a regex does not work, because I need the path for the socket name.
Currently I'm using this location:
location /application1/
{
proxy_pass http://unix:/var/run/nodejs/application1;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
the goal is to have something like:
$list = [app1, app2, app3]; #list of possible names
location /$list/ #match all names in the list
{
proxy_pass http://unix:/var/run/nodejs/$list_matched; #use matched name
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Basically every URL in a list should be redirected to the socket with the same name.
Thanks in advance for any help :)