listen 80;
server_name git.nutra.tk;
- # Define the root directory for non-Git content (optional)
- root /var/www/html;
- index index.html;
+ # Gitweb UI at root
+ location / {
+ root /usr/share/gitweb;
+ index index.cgi gitweb.cgi;
+
+ location ~ \.css$ {
+ add_header Content-Type text/css;
+ }
+ location ~ \.js$ {
+ add_header Content-Type application/javascript;
+ }
+ location ~ \.png$ {
+ add_header Content-Type image/png;
+ }
+
+ # If static file doesn't exist, pass to CGI
+ try_files $uri @gitweb;
+ }
+
+ location @gitweb {
+ include /etc/nginx/fastcgi_params;
+ fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi;
+ fastcgi_param PATH_INFO $uri;
+ fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
+ fastcgi_pass unix:/var/run/fcgiwrap.socket;
+ }
# Directory for Git repositories
set $git_root /srv/git;
- # Serve Git repositories under /git/
+ # Serve Git repositories under /git/ (Smart HTTP)
location ~ ^/git/([^/]+\.git)(/.*)?$ {
- include fastcgi_params;
+ include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
fastcgi_param GIT_PROJECT_ROOT $git_root;
- fastcgi_param GIT_HTTP_EXPORT_ALL "1"; # Allow access without git-daemon-export-ok
- fastcgi_param PATH_INFO /$1$2; # Repo name + subpath (e.g., /myrepo.git/info/refs)
+ fastcgi_param GIT_HTTP_EXPORT_ALL "1";
+ fastcgi_param PATH_INFO /$1$2;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
+ # Pass remote user for authentication (if we add auth later)
+ fastcgi_param REMOTE_USER $remote_user;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
+
+ listen 443 ssl;
+ ssl_certificate /etc/letsencrypt/live/earthyenergy.mooo.com/fullchain.pem;
+ ssl_certificate_key /etc/letsencrypt/live/earthyenergy.mooo.com/privkey.pem;
+ include /etc/letsencrypt/options-ssl-nginx.conf;
+ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
+}
+
+server {
+ if ($host = git.nutra.tk) {
+ return 301 https://$host$request_uri;
+ }
+
+ listen 80;
+ server_name git.nutra.tk;
+ return 404;
}