使用 Puppet / Nginx 添加重写位置
Add rewrite location with Puppet / Nginx
我想在 Nginx 配置文件中使用这个规则:
# Redirect old application
if ($host ~ (\w+).domain.com) {
set $root ;
}
# Redirect old application
if ($host = app1.domain.com) {
rewrite ^ $scheme://app2.domain.com permanent;
}
但我不知道如何使用标准 Nginx module
将其转移到木偶
Puppet nginx
模块具有将任意原始文本附加到位置和服务器部分的属性。例如,查看 nginx::resource::location
manifest 的完整属性列表,其中包括 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 ;
}
# Redirect old application
if ($host = app1.domain.com) {
rewrite ^ $scheme://app2.domain.com permanent;
}
END
}
我想在 Nginx 配置文件中使用这个规则:
# Redirect old application
if ($host ~ (\w+).domain.com) {
set $root ;
}
# Redirect old application
if ($host = app1.domain.com) {
rewrite ^ $scheme://app2.domain.com permanent;
}
但我不知道如何使用标准 Nginx module
将其转移到木偶Puppet nginx
模块具有将任意原始文本附加到位置和服务器部分的属性。例如,查看 nginx::resource::location
manifest 的完整属性列表,其中包括 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 ;
}
# Redirect old application
if ($host = app1.domain.com) {
rewrite ^ $scheme://app2.domain.com permanent;
}
END
}