Created
September 12, 2020 22:18
-
-
Save OneOfOne/e6f0144b240c44e657fbb5f356a186d7 to your computer and use it in GitHub Desktop.
/etc/nginx/sites.d/01-go.conf
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
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name go.oneofone.dev; | |
include conf.d/ssl.conf; # config with ssl config | |
location ~* /([^/]+) { # match the first part of the path, we only need that | |
set $pkg "$1"; | |
set $fullURI '$server_name$uri'; | |
set $pkgURI '$server_name/$pkg'; | |
set $gh 'https://github.com/OneOfOne/$pkg'; | |
set $goimp '<meta name="go-import" content="$pkgURI git $gh">\n'; | |
set $gosrc '<meta name="go-source" content="$pkgURI $gh $gh/tree/master{/dir} $gh/blob/master{/dir}/{file}#L{line}">\n'; | |
set $redir '<meta http-equiv="refresh" content="0; url=https://pkg.go.dev/$fullURI@master">\n'; | |
default_type 'text/html'; | |
return 200 '<html>\n<head>\n<title>$uri</title>\n$goimp$gosrc$redir</head>\n<body>\nthe pink stars are falling in <a href="$gh">lines</a>.\n</body>\n</html>\n'; | |
} | |
location / { | |
return 301 "https://oneofone.dev"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment