Skip to content

Instantly share code, notes, and snippets.

@tianon

tianon/nginx-go.conf

Last active Dec 13, 2016
Embed
What would you like to do?
configuration behind go.tianon.xyz, inspired by https://twitter.com/jessfraz/status/782333853117448192
# inspired by https://twitter.com/jessfraz/status/782333853117448192
# https://gist.github.com/jessfraz/421918a367a71dbaf72fdc772d809f61
# https://gist.github.com/tianon/c5ae888200d6426b167d4961d088dee2
server {
listen 80;
listen 443 ssl http2;
server_name go.tianon.xyz;
# https://github.com/infosiftr/nginx-conf.d/blob/26cea486152c658f33358f52610c9a105a264c14/set-proto.include
include conf.d/set-proto.include;
location ~ ^/([^/]+)(.*) {
# https://github.com/infosiftr/nginx-conf.d/blob/26cea486152c658f33358f52610c9a105a264c14/force-proto.include
set $force_proto "https";
include conf.d/force-proto.include;
if ($args = "go-get=1") {
add_header Content-Type text/html;
return 200 '<meta name="go-import" content="$host/$1 git https://github.com/tianon/go-$1.git">';
}
return 302 https://godoc.org/$host/$1$2;
}
location / {
# https://github.com/infosiftr/nginx-conf.d/blob/26cea486152c658f33358f52610c9a105a264c14/force-proto.include
set $force_proto "https";
include conf.d/force-proto.include;
return 302 https://github.com/tianon?tab=repositories&q=go&type=source&language=go;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.