nginx
memo
location
regex

nginx location regex tips

How to proxy pass only certain directory

eg
proxy only /doc/*/videos/*
but not like /doc/*/*/videos/*

before

/etc/nginx/conf.d/default.conf
    location ~ ^/doc/ {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

after

/etc/nginx/conf.d/default.conf
    location ~* ^/doc/[^/]*/videos/ {
        proxy_pass https://backend;
    }

    location ~ ^/doc/ {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }