Skip to content

Commit 025128d

Browse files
Byronnshcrclaude
committed
Add workaround for http CSP configuration for WebKit browsers.
WebKit's security mechanisms block HTTP requests from applications, preventing GitButler from connecting to self-hosted instances over plain HTTP even with correct CSP configuration. Document using Caddy as a local HTTPS reverse proxy as a workaround. Based on: gitbutlerapp/gitbutler#12242 (comment) Co-authored-by: nshcr <104677079+nshcr@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5741b02 commit 025128d

1 file changed

Lines changed: 46 additions & 1 deletion

File tree

content/docs/troubleshooting/custom-csp.mdx

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Custom Content Security Policy (CSP)
33
description: Configure custom Content Security Policy settings to allow GitButler connections to self-hosted GitHub, GitLab, or Ollama instances.
44
---
55

6+
import { Callout } from 'fumadocs-ui/components/callout';
67
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
78

89
By default GitButler uses a strict Content Security Policy (CSP) to protect against various attacks, such as cross-site scripting (XSS) and data injection attacks. This policy restricts the sources from which content can be loaded, as well as the hosts the application can connect to, ensuring that only trusted sources are allowed.
@@ -62,4 +63,48 @@ Note that if `extraCsp` is the only entry in the JSON file, you may want to encl
6263
}
6364
```
6465

65-
The changes will take effect the next time you start GitButler.
66+
The changes will take effect the next time you start GitButler.
67+
68+
## Connecting to HTTP instances
69+
70+
If you are trying to connect to a self-hosted instance served over plain HTTP, you may find that GitButler cannot reach it even with the correct CSP configuration. This is because WebKit (used by GitButler on macOS) blocks insecure HTTP requests from applications. Other platforms may exhibit similar behavior depending on their WebView implementation.
71+
72+
<Callout type="info">
73+
This only affects instances served over plain HTTP. If your self-hosted instance already uses HTTPS, you can skip this section.
74+
</Callout>
75+
76+
As a workaround, you can run a local HTTPS reverse proxy using [Caddy](https://caddyserver.com). Caddy automatically generates a locally-trusted TLS certificate, so GitButler sees a secure connection while your self-hosted instance continues to run over HTTP.
77+
78+
### Setting up Caddy as a local HTTPS proxy
79+
80+
The following example uses [Homebrew](https://brew.sh) on macOS, but the same approach works on any platform where Caddy is available.
81+
82+
1. Install Caddy:
83+
84+
```sh
85+
brew install caddy
86+
```
87+
88+
2. Create a `Caddyfile` (for example in `~/.config/caddy/Caddyfile`):
89+
90+
```caddyfile
91+
https://127.0.0.1:PORT {
92+
tls internal
93+
94+
reverse_proxy http://YOUR_INSTANCE:PORT {
95+
header_up Host YOUR_INSTANCE_HOSTNAME
96+
}
97+
}
98+
```
99+
100+
Replace `YOUR_INSTANCE` and `PORT` with the hostname and port of your self-hosted instance. The `header_up Host` directive ensures the original `Host` header is forwarded correctly.
101+
102+
3. Start Caddy:
103+
104+
```sh
105+
caddy run --config ~/.config/caddy/Caddyfile
106+
```
107+
108+
4. In GitButler, set your forge URL to `https://127.0.0.1:PORT` (matching the port from your Caddyfile) instead of the original HTTP URL.
109+
110+
Your self-hosted instance should now be accessible through the local HTTPS proxy.

0 commit comments

Comments
 (0)