Better proxying

This commit is contained in:
Daniel Flanagan 2024-10-15 16:38:41 -05:00
parent ffff60e036
commit 571894a6a4
2 changed files with 30 additions and 3 deletions

View file

@ -10,16 +10,16 @@ I live in Kansas City where I help run <a target="_blank"
href="https://kcrising.church">a small Christian church</a>, raise three boys href="https://kcrising.church">a small Christian church</a>, raise three boys
with my <a target="_blank" with my <a target="_blank"
href="https://www.instagram.com/valerielauren93">awesome wife</a>, and write href="https://www.instagram.com/valerielauren93">awesome wife</a>, and write
software for <a target="_blank" href="https://getdivvy.com">Divvy (bought by software for <a target="_blank" href="https://getdivvy.com">Divvy (acquired by
Bill.com)</a>. Bill.com)</a>.
I run a lot of self-hosted software here at home on some machines that sit on I run a lot of self-hosted software here at home on some machines that sit on
[an unnecessarily large server rack in my basement][rack]. I love building [an unnecessarily large server rack in my basement][rack]. I love building
[keyboards][kb], too. [I heavily customize my workflow][wf] and you can [keyboards][kb], too. [I heavily customize my workflow][wf] and you can
see how I set everything up with [Nix][nix] if you like (or even my old see how I set everything up with [Nix][nix] if you like (or even my old
[dotfiles](df)). [dotfiles][df]).
Occasionally, I post technical articles (of varying length and complexity) here. Occasionally, I post articles here.
[rack]: //files.lyte.dev/images/server-rack-angle-2023-07.jpg [rack]: //files.lyte.dev/images/server-rack-angle-2023-07.jpg
[kb]: //files.lyte.dev/keyboards [kb]: //files.lyte.dev/keyboards

View file

@ -34,3 +34,30 @@ You can use something like `go env -w GOPROXY=http://localhost:9981,direct` to
avoid prefixing all your `go` commands with the environment variable. Obviously, avoid prefixing all your `go` commands with the environment variable. Obviously,
this can cause things to break weirdly if/when the `goproxy server` dies or the this can cause things to break weirdly if/when the `goproxy server` dies or the
tunnel is disconnected. Tread lightly! tunnel is disconnected. Tread lightly!
One last possible step is that when the proxy machine clones the repo it may try
to do so over HTTPS when you almost certainly want it to use SSH. To avoid this,
you can do something like this in `~/.gitconfig` or `~/.config/git/config` to
force git to use SSH instead of HTTPS:
```ini
[url "git@git.example.com:"]
insteadOf = "https://git.example.com"
```
My full invocation looks something like this:
```shell_session
go install github.com/goproxy/goproxy/cmd/goproxy@latest
# put this cute background job somewhere or `disown`
GOPRIVATE=git.example.com GOMODCACHE=~/go goproxy server --address localhost:58320 &
```
And then on the client:
```shell_session
# put this cute background job somewhere or `disown`
ssh -L 58320:localhost:58320 $PROXYHOST &
go env -w GOPROXY=http://localhost:58320,direct
go mod tidy
```