Created
March 15, 2018 12:16
-
-
Save geoghegan/02980356651c6b625e65c27e0b2ab863 to your computer and use it in GitHub Desktop.
Gitlab go get
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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