Skip to content

Commit a04fd71

Browse files
committed
docs: add additional private network document improvement
- Add Docker Compose proxy environment configuration - Update certificate chain depth documentation - Add practical certificate extraction command - Include Cody LLM providers in external connections
1 parent dc82c14 commit a04fd71

File tree

1 file changed

+44
-19
lines changed

1 file changed

+44
-19
lines changed

docs/admin/config/private-network.mdx

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ keeping your sensitive data and operations shielded from external access.
88
When deploying self-hosted Sourcegraph instances in private networks with specific compliance and policy requirements,
99
additional configuration may be required to ensure all networking features function correctly. The reasons for applying the following configuration options depend on the specific functionality of the Sourcegraph service and the unique network and infrastructure requirements of the organization.
1010

11-
The following is a list of Sourcegraph services and how and when each initiates outbound connections to external services:
12-
11+
The following is a list of Sourcegraph services that initiate outbound connections to external services. Sourcegraph services not included in this list can be assumed to only connect to services within the Sourcegraph deployment's network segment:
1312
- **executor**: Sourcegraph [Executor](../executors) batch change or precise indexing jobs may need to connect to
1413
services hosted within an organization's private network
15-
- **frontend**: The frontend service communicates externally when connecting to external [auth providers](../auth),
16-
sending [telemetry data](../pings), testing code host connections, and connecting to [externally hosted](../external_services) Sourcegraph services
14+
- **frontend**: The frontend service communicates externally when connecting to:
15+
* External [auth providers](../auth)
16+
* Sending [telemetry data](../pings)
17+
* Testing [code host connections](../code_hosts)
18+
* Connecting to [externally hosted](../external_services) Sourcegraph services
19+
* Connecting to external [LLM providers](../../cody/capabilities/supported-models) with Cody
1720
- **gitserver**: Executes git commands against externally hosted [code hosts](../external_service)
1821
- **migrator**: Connects to Postgres instances (which may be [externally hosted](../external_services/postgres)) to process database migrations
1922
- **repo-updater**: Communicates with [code hosts](../external_service) APIs to coordinate repository synchronization
@@ -41,6 +44,18 @@ executor|frontend|gitserver|migrator|repo-updater|worker:
4144
value: "blobstore,codeinsights-db,codeintel-db,sourcegraph-frontend-internal,sourcegraph-frontend,github-proxy,gitserver,grafana,indexed-search-indexer,indexed-search,jaeger-query,pgsql,precise-code-intel-worker,prometheus,redis-cache,redis-store,repo-updater,searcher,symbols,syntect-server,worker-executors,worker,cloud-sql-proxy,localhost,127.0.0.1,.svc,.svc.cluster.local,kubernetes.default.svc"
4245
```
4346
47+
### Docker Compose
48+
49+
Add the proxy environment variables your docker compose override file.
50+
```yaml:docker-compose.override.yaml
51+
services:
52+
<service-name>:
53+
environment:
54+
- HTTP_PROXY=http://proxy.example.com:8080
55+
- HTTPS_PROXY=http://proxy.example.com:8080
56+
- NO_PROXY='blobstore,caddy,cadvisor,codeintel-db,codeintel-db-exporter,codeinsights-db,codeinsights-db-exporter,sourcegraph-frontend-0,sourcegraph-frontend-internal,gitserver-0,grafana,migrator,node-exporter,otel-collector,pgsql,pgsql-exporter,precise-code-intel-worker,prometheus,redis-cache,redis-store,repo-updater,searcher-0,symbols-0,syntect-server,worker,zoekt-indexserver-0,zoekt-webserver-0,localhost,127.0.0.1'
57+
```
58+
4459
<Callout type="warning">Failure to configure `NO_PROXY` correctly can cause the proxy configuration to interfere with
4560
local networking between internal Sourcegraph services.</Callout>
4661

@@ -68,7 +83,7 @@ Use the OpenSSL command to extract the certificate chain from your code host.
6883
Replace the domain and port with your internal code host's values:
6984

7085
```bash
71-
openssl s_client -showcerts -connect github.com:443 \
86+
openssl s_client -showcerts -connect example.com:8443 \
7287
-nameopt lname < /dev/null > certs.log 2>&1
7388
```
7489

@@ -77,16 +92,14 @@ In the generated `certs.log` file, locate the root CA certificate:
7792

7893
Certificate chains typically include 3 certificates:
7994

80-
* Root certificate authority (depth=3).
81-
* Intermediate certificate authority (depth=1).
82-
* Server (leaf) certificate (depth=0).
95+
* Root certificate authority (depth=2)
96+
* Intermediate certificate authority (depth=1)
97+
* Server (leaf) certificate (depth=0)
8398

84-
The certificate with the highest depth number in the chain will be the root CA certificate.
99+
The last certificate in the chain will be the root CA certificate and will typically have:
85100

86-
The root CA certificate will typically have:
87-
88-
* A long expiration period (years).
89-
* A descriptive common name (e.g., "Enterprise Root CA 2023").
101+
* A long expiration period (years)
102+
* A descriptive common name (e.g., "Enterprise Root CA 2023")
90103

91104
Example root CA certificate for github.com:
92105

@@ -115,12 +128,24 @@ Once you've identified the root CA certificate:
115128

116129
* Extract the certificate content including the BEGIN and END markers.
117130
* Format the certificate for the site configuration:
118-
* Replace newlines with \n characters.
119-
* Enclose the entire certificate in double quotes.
120-
* Add a trailing comma.
131+
* Replace newlines with \n characters
132+
* Enclose the entire certificate in double quotes
133+
* Add a trailing comma
134+
135+
136+
The following command can be used to easily obtain, extract, and format the root certificate from a 3 certificate chain.
137+
Be sure to adjust the hostname and port to match your internal code host. If your certificate chain is of a different
138+
depth, adjust the awk command accordingly. `awk '/BEGIN CERTIFICATE/{i++} i==X'`
139+
```bash
140+
openssl s_client -showcerts -connect example.com:8443 \
141+
-nameopt lname < /dev/null 2>&1 \
142+
| awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/' \
143+
| awk '/BEGIN CERTIFICATE/{i++} i==2' \
144+
| awk '{printf "%s\\n", $0}' | sed 's/\\n$//' \
145+
| awk '{print "\"" $0 "\","}'
146+
```
121147

122148
### Add the certificate to the site configuration
123-
124149
Add the formatted certificate to your Sourcegraph site configuration.
125150

126151
```json
@@ -156,7 +181,7 @@ Sourcegraph operations that require secure connections to internal services.
156181
1. **Code host connectivity**
157182
- Verify using the UI "Test Connection" button
158183
- Trigger validate completed sync jobs
159-
<Callout type="info">Executed by: sourcegraph-frontend service</Callout>
184+
<Callout type="info">Executed by: frontend service</Callout>
160185

161186
2. **Repository operations**
162187
- Verify individual repository synchronization
@@ -173,7 +198,7 @@ Repository-centric permission sync jobs are expected to behave identically, as t
173198

174199
### Recommended best practices
175200
* Only include root CA certificates, not intermediate or server certificates.
176-
* Avoid using insecureSkipVerify: true and add TLS certificates if needed, as it bypasses important security checks.
201+
* Avoid using `insecureSkipVerify: true` and add TLS certificates if needed, as it bypasses important security checks.
177202
* Document certificate sources and expiration dates in your organization's runbooks.
178203
* Plan for certificate rotation well before root CA expiration.
179204
* Most enterprises use a single root CA, so adding one certificate often covers all internal services.

0 commit comments

Comments
 (0)