[英]Add rewrite location with Puppet / Nginx provisionner
I'd like to use this rule in Nginx config file : 我想在Nginx配置文件中使用此规则:
location @rewriteapp {
# rewrite all to app.php
rewrite ^(.*)$ /app.php/$1 last;
}
(this rule is used for Symfony framework). (此规则用于Symfony框架)。 I used puphpet site to generate vagrant files and I modified default.pp to change the configuration of Nginx Vhost I add something like that to create this rewrite rule :
我使用puphpet网站生成了无业游民的文件,并修改了default.pp来更改Nginx Vhost的配置,我添加了类似的内容来创建此重写规则:
nginx::resource::location { "${server_name}-rewrite":
location => '@rewriteapp',
www_root => $www_root,
proxy => undef,
rewrite => '^(.*)$ /app.php/$1 last;'
}
But I get the following error : Invalid parameter rewrite at /tmp/vagrant-puppet-1/manifests/default.pp:267 on node packer-virtualbox.vagrantup.com
但是我收到以下错误:
Invalid parameter rewrite at /tmp/vagrant-puppet-1/manifests/default.pp:267 on node packer-virtualbox.vagrantup.com
Is there a way to add rewrite rule to Nginx vhost config with Puppet ? 有没有办法使用Puppet向Nginx vhost配置添加重写规则?
The problem is that rewrite is not a valid option in the nginx puppet module. 问题在于,重写不是nginx puppet模块中的有效选项。
You need to use either location_cfg_append
or location_custom_cfg
您需要使用
location_cfg_append
或location_custom_cfg
I dont have puppet setup at the moment to test but I think the syntax you need will be something like this: 我目前没有人偶设置进行测试,但我认为您需要的语法将是这样的:
nginx::resource::location { "${server_name}-rewrite":
location => '@rewriteapp',
www_root => $www_root,
proxy => undef,
location_cfg_append => {
'rewrite' => '^(.*)$ /app.php/$1 last;'
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.