簡體   English   中英

使用 Puppet 添加重寫位置 / Nginx

[英]Add rewrite location with Puppet / Nginx

我想在 Nginx 配置文件中使用此規則:

    # Redirect old application
    if ($host ~ (\w+).domain.com) {
        set $root $1;
    }

    # Redirect old application
    if ($host = app1.domain.com) {
        rewrite ^ $scheme://app2.domain.com permanent;
    }

但我無法弄清楚如何使用標准Nginx 模塊將其傳輸到人偶

Puppet nginx模塊具有將任意原始文本附加到位置和服務器部分的屬性。 例如,請參閱nginx::resource::location清單以獲取其完整的屬性列表,其中包括raw_append

理論上,您的配置可以像這樣簡單

include nginx

nginx::resource::location { 'example.com/path/'
  ensure     => present,
  location   => '/path/',
  server     => 'example.com',
  raw_append => @(END),
    # Redirect old application
    if ($host ~ (\w+).domain.com) {
        set $root $1;
    }

    # Redirect old application
    if ($host = app1.domain.com) {
        rewrite ^ $scheme://app2.domain.com permanent;
    }
    END
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM