Golang private modules conf: meta tags, git+ssh, nginx: Difference between revisions

From wikinotes
(Created page with "This configuration abstracts golang module path, <br> to provide access to private go modules over git+ssh,<br> by setting dynamic html meta tags using nginx.")
 
No edit summary
Line 2: Line 2:
to provide access to private go modules over git+ssh,<br>
to provide access to private go modules over git+ssh,<br>
by setting dynamic html meta tags using nginx.
by setting dynamic html meta tags using nginx.
= Go Package =
<blockquote>
</blockquote><!-- Go Package -->
= Package Consumers =
<blockquote>
<syntaxhighlight lang="bash">
# ~/.ssh/config
Host foo
  Hostname example.com
  IdentityFile ~/.ssh/user
  User user
</syntaxhighlight>
</blockquote><!-- Package Consumers -->
= WebServer =
<blockquote>
<syntaxhighlight lang="bash">
# /usr/local/etc/nginx/nginx.conf
location ~ ^/x/(?<go_project>[^/]+)$ {
  root /usr/local/www/example.com;
  rewrite ^ /gopkg.html;
  sub_filter '{TARGET_PROJECT}' '$go_project'
  sub_filter_once off;
}
</syntaxhighlight>
<syntaxhighlight lang="html">
<!-- /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>
</syntaxhighlight>
</blockquote><!-- WebServer -->

Revision as of 21:36, 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 user

WebServer

# /usr/local/etc/nginx/nginx.conf

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>