lundi 1 août 2016

location and variable condition

I have a problem, which in my understanding, hase gracefull solution, but I can not find it:

We have multiple frontend(static) apps:

  • appA
  • appB
  • appC

Each app has multiple branches:

  • branchZ
  • branchX
  • branchY

Feature branch URL to test served with nginx looks like the folowing

http://ift.tt/2aJytla

  • all stable apps versions stored on domain.org on local file system /opt/domain/frontend/appN
  • all feature branches stored on remote server like http://ift.tt/2ameJAr

My current nginx conf for host domain.org looks like:

server {
    listen 443;

    server_name ~^(?<app>(appA|appB|appC)?)-(?<branch>.+?)\.domain\.org$;

    # I want to send to storage_upstream only requests with ^/frontend/$app URL
    # but don't know how.
    location ~ ^/frontend/ {
        rewrite ^/frontend/(.*)$ /$app/$branch/frontend/$1 break;
        proxy_pass https://storage_upstream;
    }

I can't use $app variable in location ~ ^/frontend/ but how to make only requests with URL ^/frontend/$app to be send to storage_upstream upstream?

Aucun commentaire:

Enregistrer un commentaire