<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I have a configuration for a Docker NGINX container that works OK with my 'static' configuration, but I’d like to maybe use a variable in the proxy rewrite to avoid have to duplicate a location block for the server. A sample Static setup with some of the extra stuff removed is shown below. That actually 'works' when I explicitly specify /pacs-1/ and /pacs-2/. pacs-1 and pacs-2 happen to also be the name for other servers in my Docker Setup, so <a href="http://pacs-1:8042/" class="">http://pacs-1:8042</a> resolves to the docker container since it is called from Docker. Those servers are not accessible outside of the container, which is one reason why I proxy some requests made to it from outside of the container. I’m curious if it is possible to rewrite that such that I can match one of several container name from the request URI, e.g. something like location ~ ^<span class="hljs-regexp">/(pacs-butterfly|pacs-1|pacs-2)(/</span>.*) I tried various options, including setting a variable and nothing seems to work yet.<div class=""><br class=""></div><div class="">I could just create a separate block for each server, but it would be nice to generalize it so it would always work as long as the request uri corresponds to an existing container. Thanks.<br class=""><div class="">.</div><div class=""><br class=""></div><div class=""><div class=""> location /pacs-1/ {</div><div class=""><br class=""></div><div class=""> if ($request_method = 'OPTIONS') {</div><div class=""> <span class="Apple-tab-span" style="white-space:pre"> </span>return 204;</div><div class=""> }</div><div class=""><br class=""></div><div class=""> auth_request /auth;</div><div class=""> auth_request_set $auth_status $upstream_status;</div><div class=""> proxy_buffering off;</div><div class=""> rewrite /pacs-1/(.*) /$1 break;</div><div class=""> proxy_pass <a href="http://pacs-1:8042/" class="">http://pacs-1:8042</a>;</div><div class=""> proxy_redirect <a href="http://pacs-1:8042/" class="">http://pacs-1:8042/</a> /;</div><div class=""> proxy_set_header HOST $host;</div><div class=""><br class=""></div><div class=""> }</div><div class=""><br class=""></div><div class=""> location /pacs-2/ {</div><div class=""><br class=""></div><div class=""> if ($request_method = 'OPTIONS') {</div><div class=""> <span class="Apple-tab-span" style="white-space:pre"> </span>return 204;</div><div class=""> }</div><div class=""><br class=""></div><div class=""> auth_request /auth;</div><div class=""> auth_request_set $auth_status $upstream_status;</div><div class=""> proxy_buffering off;</div><div class=""> rewrite /pacs-2/(.*) /$1 break;</div><div class=""> proxy_pass <a href="http://pacs-2:8042/" class="">http://pacs-2:8042</a>;</div><div class=""> proxy_redirect <a href="http://pacs-2:8042/" class="">http://pacs-2:8042/</a> /;</div><div class=""> proxy_set_header HOST $host;</div><div class=""><br class=""></div><div class=""> }</div></div></div><div class=""><br class=""></div><div class="">Stephen D. Scotti</div></div></body></html>