MCPcopy Index your code
hub / github.com/coder/coder / startNginx

Function startNginx

tailnet/test/integration/integration.go:358–386  ·  view source on GitHub ↗
(t *testing.T, listenPort, serverAddr string)

Source from the content-addressed store, hash-verified

356}
357
358func startNginx(t *testing.T, listenPort, serverAddr string) {
359 cfg := `events {}
360http {
361 server {
362 listen ` + listenPort + `;
363 server_name _;
364 location / {
365 proxy_pass http://` + serverAddr + `;
366 proxy_http_version 1.1;
367 proxy_set_header Upgrade $http_upgrade;
368 proxy_set_header Connection "upgrade";
369 proxy_set_header Host $host;
370 proxy_set_header X-Real-IP $remote_addr;
371 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
372 proxy_set_header X-Forwarded-Proto $scheme;
373 proxy_set_header X-Forwarded-Host $server_name;
374 }
375 }
376}
377`
378
379 dir := t.TempDir()
380 cfgPath := filepath.Join(dir, "nginx.conf")
381 err := os.WriteFile(cfgPath, []byte(cfg), 0o600)
382 require.NoError(t, err)
383
384 // ExecBackground will handle cleanup.
385 _, _ = ExecBackground(t, "server.nginx", nil, "nginx", []string{"-c", cfgPath})
386}
387
388type BasicClientStarter struct {
389 BlockEndpoints bool

Callers 1

StartServerMethod · 0.85

Calls 3

ExecBackgroundFunction · 0.85
TempDirMethod · 0.65
WriteFileMethod · 0.65

Tested by

no test coverage detected