Golang private modules conf: meta tags, git+ssh, nginx: Difference between revisions
From wikinotes
Line 18: | Line 18: | ||
IdentityFile ~/.ssh/user | IdentityFile ~/.ssh/user | ||
User user | User user | ||
</syntaxhighlight> | |||
<syntaxhighlight lang="go"> | |||
go install example.com/x/hello | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Package Consumers --> | </blockquote><!-- Package Consumers --> |
Revision as of 21:38, 19 June 2022
This configuration abstracts golang module path,
to provide access to private go modules over git+ssh,
by setting dynamic html meta tags using nginx.
Go Package
Package Consumers
# ~/.ssh/config Host foo Hostname example.com IdentityFile ~/.ssh/user User usergo install example.com/x/hello
WebServer
# /usr/local/etc/nginx/nginx.conf http { location / { root /usr/local/www/example.com; index index.html; } location ~ ^/x/(?<go_project>[^/]+)$ { root /usr/local/www/example.com; rewrite ^ /gopkg.html; sub_filter '{TARGET_PROJECT}' '$go_project' sub_filter_once off; } }<!-- /usr/local/www/example.com/gopkg.html --> <html> <head> <meta name="go-import" content="example.com/x/{TARGET_PROJECT} git git+ssh://foo:/repos/{TARGET_PROJECT}"> </head> </html>