简体   繁体   English

使用 Puppet 添加重写位置 / Nginx

[英]Add rewrite location with Puppet / Nginx

I'd like to use this rule in Nginx config file:我想在 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;
    }

But I can't figure out how to transfer this to a puppet using the standard Nginx module但我无法弄清楚如何使用标准Nginx 模块将其传输到人偶

The Puppet nginx module has attributes for appending arbitrary raw text to location and server sections. Puppet nginx模块具有将任意原始文本附加到位置和服务器部分的属性。 For example, see the nginx::resource::location manifest for its full list of attributes, which includes raw_append .例如,请参阅nginx::resource::location清单以获取其完整的属性列表,其中包括raw_append

In theory, your configuration could be as simple as something like理论上,您的配置可以像这样简单

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