【问题标题】:mercurial hgweb cannot browse in repositories with nginxmercurial hgweb 无法使用 nginx 浏览存储库
【发布时间】:2013-07-02 16:05:09
【问题描述】:

我已安装 Mercurial,并希望使用 hgweb 在网页上也显示存储库。

我正在使用 nginx 并且我可以访问存储库所在的页面,但它似乎只是空的(我可以看到标题列 [名称、描述等.. ] 但我看不到 repo 的内容)

我正在使用 hgweb.cgi 并在那里设置 config = "/var/hg/hgweb.config" 来读取我这样定义的配置:

[paths]
/repository=/var/hg/myrepository

[extensions]
hgext.highlight =

[web]
style = gitweb
allow_push = *

注意:目录 /var/hg/myrepository/ 包含 .hg 目录。

更新

我做了更多测试,似乎 nginx 配置中有一些错误阻止了设置工作。这是我所拥有的:

    server {
      listen 443 ssl;

      ssl on;
      ssl_certificate /usr/local/nginx/conf/server.crt;
      ssl_certificate_key /usr/local/nginx/conf/server.key;

      ssl_session_timeout  20m;
      ssl_protocols  SSLv2 SSLv3 TLSv1;
      ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
      ssl_prefer_server_ciphers   on;     
      server_name webhg.server.com *.webhg.server.com;        
      root   /var/www ;

      location  /  {
        fastcgi_pass    hg-fpm;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;             
        include         fastcgi_hg;        
        auth_basic            "private!";
        auth_basic_user_file /var/hg/hg.htpasswd;
      }

      location /static/ {
         rewrite       /static/(.*)  /$1 break;
         root          /usr/share/mercurial/templates/static;
         expires 30d;
      }

    location ~ /\. {   deny all;        }        
}
## Redirect for insecure
server {
    server_name  webhg.server.com;
    listen 80;
       rewrite ^(.*) https://$host$1 permanent;
}

我可以成功访问 webhg.server.com 并且存储库列出了最后更新的日期 [因此 hgweb 以某种方式读取了此内容]。但是当我单击存储库名称或页面上的任何链接 [RSS 提要等] 时,我就回到了主页。

【问题讨论】:

  • 当你检查这个设置时,你会去http://yourserver/而不是http://yourserver/repository吗?

标签: mercurial nginx hgweb


【解决方案1】:

发现问题,

原来配置中缺少一些 fastcgi_param

现在参数是:

fastcgi_split_path_info ^(/hg)(.*)$;
fastcgi_param   SCRIPT_FILENAME  $document_root/hgweb.cgi;

fastcgi_param  PATH_INFO          $fastcgi_path_info;
fastcgi_param  AUTH_USER          $remote_user;
fastcgi_param  REMOTE_USER        $remote_user;
fastcgi_param  SERVER_PORT        $server_port;

fastcgi_param   PATH_INFO   $fastcgi_script_name;
fastcgi_param   QUERY_STRING    $query_string;
fastcgi_param   CONTENT_TYPE    $content_type;
fastcgi_param   CONTENT_LENGTH  $content_length;
fastcgi_param   SERVER_PROTOCOL $server_protocol;
fastcgi_param   SERVER_PORT $server_port;
fastcgi_param   SERVER_NAME $server_name;

这个真的很重要

fastcgi_param   REQUEST_METHOD  $request_method;

使用 SSL 时避免错误:“中止:HTTP 错误 405:推送需要 POST 请求”。

有了这个我可以浏览 mercurial 存储库

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-20
    • 2015-09-19
    • 2010-10-23
    相关资源
    最近更新 更多