0

nginx と git-web を使用していますが、うまく機能します。www.mydomain.org を使用して自分のサイトにアクセスし、gitweb をプルアップします。ここに私の設定ファイルがあります:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name www.mydomain.org;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name www.mydomain.org;

    ssl on;
    ssl_certificate /etc/nginx/ssl/mydomain_org/www_mydomain_org.crt;
    ssl_certificate_key /etc/nginx/ssl/mydomain_org/www_mydomain_org.key;
    ssl_session_timeout 5m;
    #enables all versions of TLS, but not SSLv2 or 3 which are weak and now deprecated.
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    #Disables all weak ciphers
    ssl_ciphers "Cut it out cause it was very long in question";
    ssl_prefer_server_ciphers on;

    root /var/www/html;

    auth_basic           "Restricted";
    auth_basic_user_file git_access_list;

    location /html {
        root /var/www;
        index index.html;
        access_log off;
        expires max;
    }

    # static repo files for cloning over https
    location ~ ^.*\.git/objects/([0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx))$ {
        root /media/drive1/gitrepo/;
    }

    # requests that need to go to git-http-backend
    location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
        root /media/drive1/gitrepo;

        fastcgi_pass unix:/var/run/fcgiwrap.socket;
        fastcgi_param SCRIPT_FILENAME   /usr/lib/git-core/git-http-backend;
        fastcgi_param PATH_INFO         $uri;
        fastcgi_param GIT_PROJECT_ROOT  /media/drive1/gitrepo;
        fastcgi_param GIT_HTTP_EXPORT_ALL "";
        fastcgi_param REMOTE_USER $remote_user;
        include fastcgi_params;
    }

    # send anything else to gitweb if it's not a real file
    try_files $uri @gitweb;
    location @gitweb {
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
        fastcgi_param SCRIPT_FILENAME   /usr/share/gitweb/gitweb.cgi;
        fastcgi_param PATH_INFO         $uri;
        fastcgi_param GITWEB_CONFIG     /etc/gitweb.conf;
        include fastcgi_params;
    }

    location /index.cgi {
        root /usr/share/gitweb;
        include fastcgi_params;
        gzip off;
        fastcgi_param SCRIPT_NAME $uri;
        fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
    }

    location / {
        root /usr/share/gitweb/;
        index index.cgi;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root html;
    }
}

私がやりたいのは、代わりに git サブフォルダーを用意することです。たとえば、www.mydomain.org/git を使用して、gitweb のメイン ページを表示します。それを変更する方法がよくわからず、ちょっと立ち往生しています。これを達成する方法に関するアドバイスやヒントはありますか?

ありがとう

アップデート

私は次のように変更することでそれを理解しました:

    location /index.cgi {
        root /usr/share/gitweb;
        include fastcgi_params;
        gzip off;
        fastcgi_param SCRIPT_NAME $uri;
        fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
    }

    location / {
        root /usr/share/gitweb/;
        index index.cgi;
    }

    location /git/static/ {
            alias /usr/share/gitweb/static/;
    }

    location /git/ {

            auth_basic "Restricted";
            auth_basic_user_file git_access_list;

            alias /usr/share/gitweb/;
            fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/index.cgi;
            include fastcgi_params;
            gzip off;
            fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
            fastcgi_pass unix:/var/run/fcgiwrap.socket;
    }
4

1 に答える 1

1

元の質問の更新に解決策を記載しました。しかし、ここにも追加します:

location /git/static/ {
alias /usr/share/gitweb/static/;
}

location /git/ {

auth_basic "Restricted";
auth_basic_user_file git_access_list;

alias /usr/share/gitweb/;
fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/index.cgi;
include fastcgi_params;
gzip off;
fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
于 2016-02-21T04:33:20.937 に答える