mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
feat: Add TLS support (#556)
* feat: Add TLS support This adds numerous flags with inspiration taken from Vault for configuring TLS inside Coder. This enables secure deployments without a proxy, like Cloudflare. * Update cli/start.go Co-authored-by: Colin Adler <colin@coder.com> * Fix flag help in coder.env Co-authored-by: Colin Adler <colin@coder.com>
This commit is contained in:
@ -21,16 +21,15 @@ import (
|
||||
func New(serverURL *url.URL) *Client {
|
||||
return &Client{
|
||||
URL: serverURL,
|
||||
httpClient: &http.Client{},
|
||||
HTTPClient: &http.Client{},
|
||||
}
|
||||
}
|
||||
|
||||
// Client is an HTTP caller for methods to the Coder API.
|
||||
type Client struct {
|
||||
URL *url.URL
|
||||
HTTPClient *http.Client
|
||||
SessionToken string
|
||||
|
||||
httpClient *http.Client
|
||||
URL *url.URL
|
||||
}
|
||||
|
||||
// request performs an HTTP request with the body provided.
|
||||
@ -71,7 +70,7 @@ func (c *Client) request(ctx context.Context, method, path string, body interfac
|
||||
opt(req)
|
||||
}
|
||||
|
||||
resp, err := c.httpClient.Do(req)
|
||||
resp, err := c.HTTPClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("do: %w", err)
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ func (c *Client) ListenProvisionerDaemon(ctx context.Context) (proto.DRPCProvisi
|
||||
return nil, xerrors.Errorf("parse url: %w", err)
|
||||
}
|
||||
conn, res, err := websocket.Dial(ctx, serverURL.String(), &websocket.DialOptions{
|
||||
HTTPClient: c.httpClient,
|
||||
HTTPClient: c.HTTPClient,
|
||||
// Need to disable compression to avoid a data-race.
|
||||
CompressionMode: websocket.CompressionDisabled,
|
||||
})
|
||||
|
@ -30,7 +30,7 @@ func (c *Client) AuthWorkspaceGoogleInstanceIdentity(ctx context.Context, servic
|
||||
serviceAccount = "default"
|
||||
}
|
||||
if gcpClient == nil {
|
||||
gcpClient = metadata.NewClient(c.httpClient)
|
||||
gcpClient = metadata.NewClient(c.HTTPClient)
|
||||
}
|
||||
// "format=full" is required, otherwise the responding payload will be missing "instance_id".
|
||||
jwt, err := gcpClient.Get(fmt.Sprintf("instance/service-accounts/%s/identity?audience=coder&format=full", serviceAccount))
|
||||
|
Reference in New Issue
Block a user