Skip to content

Instantly share code, notes, and snippets.

@geoghegan
Created March 15, 2018 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geoghegan/02980356651c6b625e65c27e0b2ab863 to your computer and use it in GitHub Desktop.
Save geoghegan/02980356651c6b625e65c27e0b2ab863 to your computer and use it in GitHub Desktop.
Gitlab go get
# Use the below in your nginx config to allow `go get` to be used for self-hosted gitlab repos.
server {
server_name code.example.com;
# define error page
error_page 404 = @notfound;
# error page location redirect 301
location @notfound {
return 301 https://gitlab.example.com;
}
# default location on code.example.com should redirect (not covered under 404 redirect)
location / {
return 301 https://gitlab.example.com;
}
# This is the part that tells go-get to use gitlab.example.com instead of code.example.com
location ~ "(/[^/]+/[^/]+)(/.*)?" {
if ($arg_go-get = "1") {
return 200 '<html>\n<head>\n<meta name="go-import" content="code.example.com$1 git https://gitlab.example.com$1"/>\n</head>\n<body>\ngo get gitlab.example.com$1\n</body>\n</html>';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment