AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 485986
Accepted
growse
growse
Asked: 2013-03-09 06:10:42 +0800 CST2013-03-09 06:10:42 +0800 CST 2013-03-09 06:10:42 +0800 CST

Puppet 通过 nginx 服务插件抛出 404s

  • 772

我迁移了我的 puppet master 设置以在 thin 下运行,文件由 nginx 提供。

模块文件服务很好,但插件文件似乎不起作用。日志认为代理正在请求类似的 url /production/file_content/plugins/puppet/provider/exec/powershell.rb,因此 nginx 抛出 404,因为不存在这样的路径。这在 WEBrick 上运行良好。

从理论上讲,这应该是编写类似于下面的模块规则的重写规则的简单情况。然而,很多这些提供者都在模块中,所以这个特定的提供者在/etc/puppet/modules/powershell/lib/puppet/provider/exec/powershell.rb.

当它们可能分散在各种模块目录中时,如何从请求 URL 映射到实际插件?

我的 nginx 配置如下所示:

upstream puppetmaster-thin {                                                                                                                                                          
    server  unix:/var/run/puppet/puppetmasterd.0.sock;                                                                                                                                
    server  unix:/var/run/puppet/puppetmasterd.1.sock;                                                                                                                                
    server  unix:/var/run/puppet/puppetmasterd.2.sock;                                                                                                                                
}                                                                                                                                                                                     

server {                                                                                                                                                                              
    listen  8140;                                                                                                                                                                     
    root    /etc/puppet/rack;                                                                                                                                                         

    ssl                     on;                                                                                                                                                       
    ssl_session_timeout     5m;                                                                                                                                                       
    ssl_certificate         /var/lib/puppet/ssl/certs/gcspuppet01.pem;                                                                                                                
    ssl_certificate_key     /var/lib/puppet/ssl/private_keys/gcspuppet01.pem;                                                                                                         
    ssl_client_certificate  /var/lib/puppet/ssl/ca/ca_crt.pem;                                                                                                                        
    ssl_crl                 /var/lib/puppet/ssl/ca/ca_crl.pem;                                                                                                                        
    ssl_verify_client       optional;                                                                                                                                                 
    ssl_ciphers             SSLv2:-LOW:-EXPORT:RC4+RSA;                                                                                                                               

    proxy_read_timeout  120;                                                                                                                                                          
    proxy_redirect      off;                                                                                                                                                          

    proxy_set_header   Host             $host;                                                                                                                                        
    proxy_set_header   X-Real-IP        $remote_addr;                                                                                                                                 
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;                                                                                                                   
    proxy_set_header   X-Client-Verify  $ssl_client_verify;                                                                                                                           
    proxy_set_header   X-Client_DN      $ssl_client_s_dn;                                                                                                                             
    proxy_set_header   X-SSL-Subject    $ssl_client_s_dn;                                                                                                                             
    proxy_set_header   X-SSL-Issuer     $ssl_client_i_dn;                                                                                                                             


    location /production/file_content/ {                                                                                                                                              
    location /production/file_content/extra_files/ {                                                                                                                              
        alias /etc/puppet/files/;                                                                                                                                                 
    }                                                                                                                                                                             
    rewrite ^/production/file_content/modules/([^/]+)/(.*) /$1/files/$2;                                                                                                          
    break;                                                                                                                                                                        
    root /etc/puppet/modules/;                                                                                                                                                    
    }                                                                                                                                                                                 
    location / {                                                                                                                                                                      
    proxy_pass          http://puppetmaster-thin;                                                                                                                                 
    }                                                                                                                                                                                 
}         
nginx
  • 1 1 个回答
  • 236 Views

1 个回答

  • Voted
  1. Best Answer
    growse
    2013-03-09T07:08:17+08:002013-03-09T07:08:17+08:00

    我想到了。问题在于 nginx 正在有效地尝试提供对/production/file_content/. 这样做的问题是,虽然这对于从 下的模块提供文件很有用/production/file_content/modules/,但它会劫持/production/file_content/plugins.

    因为插件路径是“魔法”的,所以它们需要由 puppet master 守护进程处理,而不是由 nginx 处理。解决方案是编写一个更好的 nginx 配置文件:

    location /production/file_content/extra_files/ {                                                                                                                                  
        alias /etc/puppet/files/;                                                                                                                                                     
    }                                                                                                                                                                                 
    location /production/file_content/modules/ {                                                                                                                                      
        rewrite ^/production/file_content/modules/([^/]+)/(.*) /$1/files/$2;                                                                                                          
        break;                                                                                                                                                                        
        root /etc/puppet/modules/;                                                                                                                                                    
    }           
    
    • 1

相关问题

  • Gzip 与反向代理缓存

  • nginx 作为代理的行为

  • Nginx 学习资源 [关闭]

  • 提供 70,000 个静态文件 (jpg) 的最佳方式?

  • 在 Apache、LightTPD 和 Nginx Web 服务器上提供 PHP 5.x 应用程序的现状?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve