why
++ No reason. Perhaps to host personal files in the future. AWS's + micro free tier is great, too. +
+what
+-
+
- Write my own git web ui +
- Support clones from my own website +
- Host private files on my git ui +
the process
+-
+
- + Create the ec2 instance with setup wizard and add {in,out}bound + rules for {SSH,HTTP,HTTPS,your ip} in the wizard security group. + +
- + Use an elastic ip (free) to address public ip + reassigning—this is a bother when ssh'ing (new verb?) into + the box locally and/or configuring an Apache HTTP server. + +
- Understand bare git repositories and the ssh protocol. +
-
+ Configure an keypair and ssh in (the official instructions are
+ fine for this). I moved it to
~/.sshand added an + alias in~/.ssh/configfor convenience. Clone a repo + on the server to test. +
+ -
+ Set up a git daemon for
git://protocol cloning at + your own risk. +
+ - Set up an Apache HTTPD server. +
-
+ Configure file permissions for the new user:
+
-
+
sudo chown -R git:git /srv/git
+ sudo chgrp -R apache /srv/git
+
+ -
+ To deal with "dubious ownership" issues when cloning with HTTPS, I
+ needed to add exactly the following configuration to
+
/etc/gitconfig. + No group permission finagling will work! Git only allows + cloning repositories that are owned by the user. If you wish to + clone via SSH with, say, user A, this same user must also be + employed by your HTTP server to clone the files (customize + HTTPD/whatever you're using accordingly). +
+
+ -
+ Security-wise, set up TLS/HTTPS with
+ Let's Encrypt. Further, only allow authorized people to actually
+ push to the server. The following is my HTTPD configuration
+ file
+
/etc/apache/conf.d/git-server.conf+ hosting the web ui at the root and clone urls at +/git: +
+
+ -
+ There are a variety of choices for web ui, including
+ cgit,
+ gitweb
+ (I do not recommend this—the scripts are ancient and require
+ manual tuning), and some even heavier options that allow for
+ further customization. I am not a fan of viewing code on the web,
+ so you cannot in
+ my custom ui. I spin up a simple python server to walk the projects in
+
/srv/gitand configured a systemd service to run it + in the ec2 box: +
+
+ I detail self-hosting a git server on an AWS t2.micro instance + ("free" for 1 year) as of May 2025. + Git's instructions + were vastly outdated so hopefully this saves a lucky reader some + time. +
+
+
+ lessons
+-
+
- + It feels great to do things yourself: I used GPT-4o for + linux server command help, that was about it + +
- + Always ask "what is this?" before using something: this + would've saved me hours of realizing a 12 year old perl script + should not have been running my git ui. + +