{"id":3491,"date":"2016-08-27T15:37:43","date_gmt":"2016-08-27T13:37:43","guid":{"rendered":"https:\/\/adrhc.go.ro\/wordpress\/?p=3491"},"modified":"2019-04-08T19:21:24","modified_gmt":"2019-04-08T17:21:24","slug":"gitweb-nginx","status":"publish","type":"post","link":"https:\/\/adrhc.go.ro\/blog\/gitweb-nginx\/","title":{"rendered":"gitweb on nginx"},"content":{"rendered":"<pre><strong>nginx configuration<\/strong>\r\n# Let Nginx handle static files\r\n# location ~ ^.*\\.git\/objects\/([0-9a-f]+\/[0-9a-f]+|pack\/pack-[0-9a-f]+.(pack|idx)) {\r\nlocation ~ ^\/[^\/]*\\.git\/objects\/([0-9a-f]+\/[0-9a-f]+|pack\/pack-[0-9a-f]+.(pack|idx)) {\r\n\tauth_basic\t\t\t\t\"strong authentication\";\r\n    auth_basic_user_file\t\/********\/apps\/etc\/basic.auth.strong.passwords.txt;\r\n    root \/********\/GITRepoUbuntu\/;\r\n}\r\n\r\n# Pass Git Smart HTTP requests to git-http-backend. Require Auth for everything.\r\n# see man git-http-backend for Apache configuration\r\n#location ~ ^.*\\.git\/(HEAD|info\/refs|objects\/info\/.*|git-(upload|receive)-pack)$ {\r\nlocation ~ ^\/[^\/]*\\.git\/(HEAD|info\/refs|objects\/info\/.*|git-(upload|receive)-pack)$ {\r\n\tauth_basic\t\t\t\t\t\t\t\t\t\"strong authentication\";\r\n    auth_basic_user_file\t\t\t\t\t\t\/********\/apps\/etc\/basic.auth.strong.passwords.txt;\r\n\tclient_max_body_size\t\t\t\t\t\t0;\r\n\tfastcgi_read_timeout\t\t\t\t\t\t300;\r\n\tfastcgi_buffers\t\t\t\t\t\t\t\t4 64K;\r\n    include        \t\t\t\t\t\t\t\tfastcgi_params;\r\n    fastcgi_pass   \t\t\t\t\t\t\t\tunix:\/var\/run\/fastcgi.sock;\r\n    fastcgi_param  \t\t\tSCRIPT_FILENAME\t\t\/usr\/lib\/git-core\/git-http-backend;\r\n    fastcgi_param  \t\t\tGIT_PROJECT_ROOT\t\/********\/GITRepoUbuntu;\r\n    fastcgi_param  \t\t\tPATH_INFO\t\t\t$uri;\r\n    fastcgi_param  \t\t\tREMOTE_USER\t\t\t$remote_user;\r\n    ### Uncomment below to export ALL repositories in GIT_PROJECT_ROOT path.\r\n    fastcgi_param  \t\t\tGIT_HTTP_EXPORT_ALL\t\"\";\r\n}\r\n\r\nlocation \/git\/ {\r\n\tauth_basic\t\t\t\t\"strong authentication\";\r\n    auth_basic_user_file\t\/********\/apps\/etc\/basic.auth.strong.passwords.txt;\r\n\ttry_files $uri @gitweb;\r\n}\r\n\r\nlocation @gitweb {\r\n    fastcgi_pass \t\t\tunix:\/var\/run\/fastcgi.sock;\r\n    fastcgi_param \t\t\tSCRIPT_FILENAME   \/usr\/share\/gitweb\/gitweb.cgi;\r\n    fastcgi_param \t\t\tPATH_INFO         $uri;\r\n    fastcgi_param \t\t\tGITWEB_CONFIG     \/etc\/gitweb.conf;\r\n    include\t\t\t\t\tfastcgi_params;\r\n}\r\n\r\n# sudo systemctl status nginx fcgiwrap.service fcgiwrap.socket\r\n# sudo systemctl enable nginx fcgiwrap.service fcgiwrap.socket\r\n# sudo systemctl stop nginx fcgiwrap.service fcgiwrap.socket\r\n# sudo systemctl start fcgiwrap.socket fcgiwrap.service nginx\r\n\r\n<strong>\/etc\/gitweb.conf<\/strong>                                                                                                                   \r\n#see man gitweb\r\n \r\n# path to git projects (<project>.git)\r\n$projectroot = \"\/********\/GITRepoUbuntu\/\";\r\n \r\n# directory to use for temp files\r\n# $git_temp = \"\/tmp\";\r\n \r\n# html text to include at home page\r\n# $home_text = \"indextext.html\";\r\n \r\n# file with project list; by default, simply scan the projectroot dir.\r\n# $projects_list = \"\/home\/git\/projects.list\";\r\n \r\n@stylesheets = (\"gitweb.css\");\r\n$javascript = \"gitweb.js\";\r\n$favicon = \"git-favicon.png\";\r\n$logo = \"git-logo.png\";\r\n \r\n# git-diff-tree(1) options to use for generated patches\r\n@diff_opts = ('-C', '-C');\r\n \r\n# enable nicer uris\r\n# $feature{pathinfo}{default} = [1];\r\n \r\n$site_name = \"adrhc's projects\";\r\n$home_link = \"https:\/\/adrhc.go.ro\/git\/\";\r\n$home_link_str = \"adrhc's projects\";\r\n$mimetypes_file = \"\/********\/apps\/etc\/nginx\/mime.types\";\r\n$base_url = \"https:\/\/adrhc.go.ro\/git\/\";\r\n@git_base_url_list = qw(https:\/\/adrhc.go.ro);\r\n@extra_breadcrumbs = (\r\n        [ \"adrhc's blog\" => \"https:\/\/adrhc.go.ro\/\" ]\r\n);\r\n\r\n<strong>\/etc\/systemd\/system\/fcgiwrap.socket<\/strong>\r\n[Unit]\r\nDescription=fcgiwrap Socket\r\n\r\n[Socket]\r\nSocketMode=0660\r\nSocketUser****\r\nSocketGroup*********\r\nListenStream=\/var\/run\/fastcgi.sock\r\n\r\n[Install]\r\nWantedBy=sockets.target\r\n\r\n<strong>\/etc\/systemd\/system\/fcgiwrap.service<\/strong>\r\n[Unit]\r\nDescription=Simple CGI Server\r\nAfter=nss-user-lookup.target\r\n\r\n[Service]\r\n# https:\/\/apuntesderootblog.wordpress.com\/2015\/06\/01\/how-to-run-gitweb-and-git-http-backend-with-nginx-in-fedora\/\r\n# sudo apt-get install fcgiwrap\r\n# systemctl daemon-reload\r\n# sudo systemctl enable fcgiwrap.socket fcgiwrap.service\r\nExecStartPre=\/bin\/mkdir -p \/var\/cache\/cgit\r\nExecStartPre=\/bin\/chown ************ \/var\/cache\/cgit\r\n#ExecStartPre=\/bin\/rm -rf \/var\/cache\/cgit\/*\r\nExecStart=\/usr\/sbin\/fcgiwrap\r\nUser****\r\nGroup*********\r\n\r\n[Install]\r\nAlso=fcgiwrap.socket\r\n\r\n<strong>example bare repository config<\/strong>\r\ncat \/********\/GITRepoUbuntu\/test\/git\/config\r\n[core]\r\n        repositoryformatversion = 0\r\n        filemode = false\r\n        bare = true\r\n        sharedrepository = 1\r\n[receive]\r\n        denyNonFastforwards = true\r\n[alias]\r\n        st = status\r\n        gr = log --full-history --all --graph --color --date-order --pretty=format:\"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s\"\r\n        ci = commit\r\n        cim = commit -m\r\n        ck = checkout\r\n        ckm = checkout master\r\n        ckd = checkout dev\r\n        rs = reset\r\n        mgnf = merge --no-ff\r\n        mg = merge\r\n        pom = push origin master\r\n        pod = push origin development\r\n        gom = pull origin master\r\n        god = pull origin development\r\n[gitg]\r\n        mainline = refs\/heads\/master\r\n\r\n# ERROR\r\n\tgit clone https:\/\/adrhc.go.ro\/exifweb.git\r\n\tedit some files then commit ...\r\n\tgit push origin master\r\n\tCounting objects: 3, done.\r\n\tDelta compression using up to 4 threads.\r\n\tCompressing objects: 100% (3\/3), done.\r\n\tWriting objects: 100% (3\/3), 303 bytes | 0 bytes\/s, done.\r\n\tTotal 3 (delta 2), reused 0 (delta 0)\r\n\tremote: error: unable to create temporary file: Operation not permitted\r\n\tremote: fatal: failed to write object\r\n\terror: unpack failed: unpack-objects abnormal exit\r\n\tTo https:\/\/adrhc.go.ro\/exifweb.git\r\n\t ! [remote rejected] master -> master (unpacker error)\r\n\terror: failed to push some refs to 'https:\/\/adrhc.go.ro\/exifweb.git'\r\n# SOLUTION\r\n\tMake sure the user and group (and SocketMode) set for fcgiwrap OS service are appropriate for the git repository (when using http\/https push).\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>nginx configuration # Let Nginx handle static files # location ~ ^.*\\.git\/objects\/([0-9a-f]+\/[0-9a-f]+|pack\/pack-[0-9a-f]+.(pack|idx)) { location ~ ^\/[^\/]*\\.git\/objects\/([0-9a-f]+\/[0-9a-f]+|pack\/pack-[0-9a-f]+.(pack|idx)) { auth_basic &#8220;strong authentication&#8221;; auth_basic_user_file \/********\/apps\/etc\/basic.auth.strong.passwords.txt; root \/********\/GITRepoUbuntu\/; } # Pass Git Smart HTTP requests to git-http-backend. Require Auth for everything. # see man [&hellip;]<\/p>\n<div class=\"link-more\"><a href=\"https:\/\/adrhc.go.ro\/blog\/gitweb-nginx\/#more-3491\" class=\"more-link\">Continue reading &#10142; <span class=\"screen-reader-text\">gitweb on nginx<\/span><\/a><\/div>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,44,11,10],"tags":[93,100],"class_list":["post-3491","post","type-post","status-publish","format-standard","hentry","category-configuration","category-http-web-server","category-linux","category-programming","tag-gitweb","tag-nginx"],"_links":{"self":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts\/3491","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/comments?post=3491"}],"version-history":[{"count":0,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts\/3491\/revisions"}],"wp:attachment":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/media?parent=3491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/categories?post=3491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/tags?post=3491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}