I'd like to use this rule in Nginx config file:
# 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
The Puppet nginx
module has attributes for appending arbitrary raw text to location and server sections. For example, see the nginx::resource::location
manifest for its full list of attributes, which includes 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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.