Nginx的性能比WEBRICK高很多,下面介绍如何替换WEBRICK
.安装passenger和nginx的步骤参考:Centos 安装 Nginx+passenger及同puppet-dashboard结合
通过命令启动Nginx,
/opt/nginx/sbin/nginx
查看nginx是否安装成功
现在配置Nginx;
在 /opt/nginx/conf/conf.d目录下新建配置文件 master.domain.com.conf :
server {
listen 8140 ssl;
server_name master master.domain.com;
root /etc/puppet/rack/public;
passenger_enabled on;
passenger_set_header X_CLIENT_DN $ssl_client_s_dn;
passenger_set_header X_CLIENT_VERIFY $ssl_client_verify;
access_log /var/log/nginx/master.domain.com_access.log;
error_log /var/log/nginx/master.domain.com_error.log;
ssl_certificate /var/lib/puppet/ssl/certs/master.domain.com.pem;
ssl_certificate_key /var/lib/puppet/ssl/private_keys/master.domain.com.pem;
ssl_crl /var/lib/puppet/ssl/ca/ca_crl.pem;
ssl_client_certificate /var/lib/puppet/ssl/certs/ca.pem;
ssl_ciphers SSLv2:-LOW:-EXPORT:RC4+RSA;
ssl_prefer_server_ciphers on;
ssl_verify_client optional;
ssl_verify_depth 1;
ssl_session_cache shared:SSL:128m;
ssl_session_timeout 5m;
}
并且将 /opt/nginx/conf/nginx.conf的文件配置如下
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
#配置passenger模块
passenger_root /usr/lib64/ruby/gems/1.8/gems/passenger-5.0.20;
passenger_ruby /usr/bin/ruby;
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#server {
#listen 80;
#server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
# root html;
# index index.html index.htm;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root html;
#}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
#}
include /opt/nginx/conf/conf.d/*.conf;
}
1 配置passenger模块
2 添加配置文件include /opt/nginx/conf/conf.d/*.conf;
3 注释server,没有必要配置多个虚拟主机
配置结束之后,在/etc/puppet/auth.conf中最后添加
# deny everything else; this ACL is not strictly necessary, but
# illustrates the default policy.
path /
auth any
allow *
一定要allow * 否则汇报request 403的错误。我在使用原生态webrick的时候,不加allow * 程序正常运行,但是改为Nginx之后,不加就报错,巨坑。
关闭 puppetmaster服务器,否则8140端口会被占用
service puppetmaster stop
chkconfig puppetmaster off
在agent中测试
puppet agent --onetime --no-daemonize --verbose --noop
替换成功。