if-statement-使用Puppet Nginx jfryman模块将if else置于nginx Vhost配置中
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了if-statement-使用Puppet Nginx jfryman模块将if else置于nginx Vhost配置中,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2309字,纯文字阅读大概需要4分钟。
内容图文
![if-statement-使用Puppet Nginx jfryman模块将if else置于nginx Vhost配置中](/upload/InfoBanner/zyjiaocheng/946/5cd837e04b1b4eeca328f941f2d3e091.jpg)
我想为一个具有一些if条件语句的网站自动执行nginx vhost配置.我试图使用jfryman-nginx人偶伪造模块来执行此操作,但无法配置该文件.我想要的配置如下:
server {
listen 8080;
server_name abcqwe.com;
root /data/vvv/abcqwe.com;
index index.php index.html index.htm;
access_log /data/vvv/abcqwe.com/logs/access.log;
error_log /data/vvv/abcqwe.com/logs/error.log;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
#try_files $uri $uri/ /index.html;
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
try_files $uri $uri/ /index.html;
}
因此,如果条件在我的vhost配置中,我该如何放置它:
if (!-f $request_filename){
set $rule_4 1$rule_4;
}
可以吗?我已经尝试过location_cfg_prepend,但这没有帮助.
解决方法:
我对jfryman-nginx v0.0.9遇到了同样的问题.
In the latest source templates on github,看起来像;如果您使用location_custom_cfg_ {pre,ap} pend,则不应添加.
但是in v0.0.9, the latest bundled puppet forge release,模板添加了;即使该行仅包含},也会导致nginx失败.
解决方案:
>使用location _ ** custom ** _ cfg_ {pre,ap}挂起选项
> A或B:
A.编辑出;在模板中
B.从github拉取最新版本的源代码:
须藤rm -rf / etc / puppet / modules / nginx&& cd / etc / puppet / modules&&须藤git clone https://github.com/jfryman/puppet-nginx nginx
例
nginx::resource::location { 'sub.dom.com_root':
ensure => present,
vhost => 'sub.dom.com',
location => '~ \.php$',
fastcgi => 'unix:/var/run/php5-fpm.sock',
www_root => '/var/www/sub.dom.com',
location_custom_cfg_append => {
'if (-f $request_filename)' => '{ break; }',
'if (-d $request_filename)' => '{ break; }',
'if ($request_filename !~ (js|css|jpg|png|gif|robots\.txt|index\.php.*) )' => '{ rewrite ^/(.*) /index.php?$1 last; }',
},
}
内容总结
以上是互联网集市为您收集整理的if-statement-使用Puppet Nginx jfryman模块将if else置于nginx Vhost配置中全部内容,希望文章能够帮你解决if-statement-使用Puppet Nginx jfryman模块将if else置于nginx Vhost配置中所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。