Created
August 21, 2015 01:36
-
-
Save jpillora/2eb0449b166ef8452ed9 to your computer and use it in GitHub Desktop.
Gitlab go get via SSH
This file contains hidden or 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
server { | |
listen {PUBLIC-GITLAB-HTTP-PORT}; #e.g. 80 | |
server_name {PUBLIC-GITLAB-HOST}; #e.g. git.mycompany.com | |
# add_header X-Frame-Options DENY; | |
add_header X-Content-Type-Options nosniff; | |
location / { | |
## Hack to implement && - Concat two strings and compare result | |
if ($args ~* "^go-get=1") { | |
set $condition goget; | |
} | |
if ($uri ~ ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$) { | |
set $condition "${condition}path"; | |
} | |
if ($condition = gogetpath) { | |
return 200 "<!DOCTYPE html><html><head><meta content='{PUBLIC-GITLAB-HOST}$uri git ssh://git@{PUBLIC-GITLAB-HOST}:{PUBLIC-GITLAB-SSH-PORT}$uri.git' name='go-import'></head></html>"; | |
} | |
## https://github.com/gitlabhq/gitlabhq/issues/694 | |
## Some requests take more than 30 seconds. | |
proxy_read_timeout 300; | |
proxy_connect_timeout 300; | |
proxy_redirect off; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-Ssl off; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header X-Frame-Options SAMEORIGIN; | |
# Proxy to gitlab | |
proxy_pass http://{PRIVATE-GITLAB-HOST}:{PRIVATE-GITLAB-HTTP-PORT}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment