Skip to content

fix: direct embedded derp traffic directly to the server#6595

Merged
kylecarbs merged 1 commit into
mainfrom
internalderp
Mar 14, 2023
Merged

fix: direct embedded derp traffic directly to the server#6595
kylecarbs merged 1 commit into
mainfrom
internalderp

Conversation

@kylecarbs
Copy link
Copy Markdown
Member

Prior to this change, DERP traffic would route from coderd to the CODER_ACCESS_URL to reach the internal DERP server, which may have resulted in slower connections due to proxying, or the failure of web traffic entirely.

If your Coder deployment has a proxy in front of it, your traffic through web terminals, apps, and port-forwarding is about to get a lot faster!

See coder/tailscale#13

@kylecarbs kylecarbs self-assigned this Mar 14, 2023
@kylecarbs kylecarbs requested a review from mafredri March 14, 2023 14:01
Comment thread coderd/workspaceagents.go Outdated
Addresses: []netip.Prefix{netip.PrefixFrom(tailnet.IP(), 128)},
DERPMap: derpMap,
Logger: api.Logger.Named("tailnet"),
BlockEndpoints: true,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we set BlockEndpoints now? I'm sure there's a reason, just wondering. 😄

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a mistake! Fantastic catch 🥴🥴🥴

Comment thread coderd/workspaceagents.go
_ = serverConn.Close()
return nil, xerrors.Errorf("create tailnet conn: %w", err)
}
conn.SetDERPRegionDialer(func(_ context.Context, region *tailcfg.DERPRegion) net.Conn {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a comment above in the code that seems outdated now?

		// TODO: This should dial directly to execute the
		// DERP server instead of contacting localhost.
		//
		// This requires modification of Tailscale internals
		// to pipe through a proxy function per-region, so
		// this is an easy and mostly reliable hack for now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point! I'm happy we're able to take out a TODO!

Prior to this change, DERP traffic would route from `coderd` to the
`CODER_ACCESS_URL` to reach the internal DERP server, which may have
resulted in slower connections due to proxying, or the failure of
web traffic entirely.

If your Coder deployment has a proxy in front of it, your traffic through
web terminals, apps, and port-forwarding is about to get a lot faster!
@kylecarbs kylecarbs enabled auto-merge (squash) March 14, 2023 14:41
@kylecarbs kylecarbs merged commit 17bc579 into main Mar 14, 2023
@kylecarbs kylecarbs deleted the internalderp branch March 14, 2023 14:46
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants