位置和可变条件

时间:2016-08-01 15:33:23

标签: testing nginx frontend nginx-location

我有一个问题,在我的理解中,有一个优雅的解决方案,但我找不到它:

我们有多个前端(静态)应用程序:

  • 的appA
  • appB的
  • APPC

每个应用都有多个分支:

  • branchZ
  • branchX

使用nginx测试的功能分支URL看起来像下面的

https://appB-branchY.domain.org/index.html

  • 存储在domain.org本地文件系统/opt/domain/frontend/appN
  • 上的所有稳定应用版本
  • 存储在远程服务器上的所有功能分支,如https://storage.org/appN/branchZ

我对主机domain.org的当前nginx配置如下:

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;
    }

我无法在$app中使用location ~ ^/frontend/变量,但如何仅将包含网址^/frontend/$app的请求发送到上游的storage_upstream

0 个答案:

没有答案
相关问题