|
| 1 | +--- |
| 2 | +title: Configuration |
| 3 | +description: VPN provider, server selection, proxy, and firewall configuration for Gluetun |
| 4 | +--- |
| 5 | +import NugetBadge from '/src/components/NugetBadge.tsx'; |
| 6 | + |
| 7 | +<NugetBadge name="Shiny.Aspire.Hosting.Gluetun" showLabel={true} /> |
| 8 | + |
| 9 | +## VPN Provider |
| 10 | + |
| 11 | +Every Gluetun setup requires a VPN service provider: |
| 12 | + |
| 13 | +```csharp |
| 14 | +var vpn = builder.AddGluetun("vpn") |
| 15 | + .WithVpnProvider("mullvad"); |
| 16 | +``` |
| 17 | + |
| 18 | +See the [Gluetun wiki](https://github.com/qdm12/gluetun-wiki) for the full list of supported providers. |
| 19 | + |
| 20 | +## VPN Protocol |
| 21 | + |
| 22 | +### WireGuard |
| 23 | + |
| 24 | +```csharp |
| 25 | +// String key (for development/testing) |
| 26 | +vpn.WithWireGuard("my-private-key"); |
| 27 | + |
| 28 | +// Aspire parameter resource (recommended for secrets) |
| 29 | +vpn.WithWireGuard(builder.AddParameter("wireguard-key", secret: true)); |
| 30 | +``` |
| 31 | + |
| 32 | +Sets `VPN_TYPE=wireguard` and `WIREGUARD_PRIVATE_KEY`. |
| 33 | + |
| 34 | +### OpenVPN |
| 35 | + |
| 36 | +```csharp |
| 37 | +// String credentials (for development/testing) |
| 38 | +vpn.WithOpenVpn("username", "password"); |
| 39 | + |
| 40 | +// Aspire parameter resources (recommended for secrets) |
| 41 | +vpn.WithOpenVpn( |
| 42 | + builder.AddParameter("openvpn-user"), |
| 43 | + builder.AddParameter("openvpn-pass", secret: true)); |
| 44 | +``` |
| 45 | + |
| 46 | +Sets `VPN_TYPE=openvpn`, `OPENVPN_USER`, and `OPENVPN_PASSWORD`. |
| 47 | + |
| 48 | +## Server Selection |
| 49 | + |
| 50 | +```csharp |
| 51 | +vpn.WithServerCountries("US", "Canada", "Germany"); |
| 52 | +vpn.WithServerCities("New York", "Toronto"); |
| 53 | +``` |
| 54 | + |
| 55 | +Values are comma-joined and set as `SERVER_COUNTRIES` / `SERVER_CITIES` environment variables. |
| 56 | + |
| 57 | +## Proxy Features |
| 58 | + |
| 59 | +Gluetun includes built-in HTTP and Shadowsocks proxies: |
| 60 | + |
| 61 | +```csharp |
| 62 | +vpn.WithHttpProxy(); // HTTPPROXY=on |
| 63 | +vpn.WithHttpProxy(false); // HTTPPROXY=off |
| 64 | +vpn.WithShadowsocks(); // SHADOWSOCKS=on |
| 65 | +vpn.WithShadowsocks(false); // SHADOWSOCKS=off |
| 66 | +``` |
| 67 | + |
| 68 | +To expose the proxy ports, pass them when creating the resource: |
| 69 | + |
| 70 | +```csharp |
| 71 | +var vpn = builder.AddGluetun("vpn", httpProxyPort: 8888, shadowsocksPort: 8388) |
| 72 | + .WithHttpProxy() |
| 73 | + .WithShadowsocks(); |
| 74 | +``` |
| 75 | + |
| 76 | +## Network & Firewall |
| 77 | + |
| 78 | +```csharp |
| 79 | +vpn.WithFirewallOutboundSubnets("10.0.0.0/8", "192.168.0.0/16"); |
| 80 | +vpn.WithTimezone("America/New_York"); |
| 81 | +``` |
| 82 | + |
| 83 | +`WithFirewallOutboundSubnets` sets `FIREWALL_OUTBOUND_SUBNETS`, useful for allowing traffic to local network resources outside the VPN tunnel. |
| 84 | + |
| 85 | +## Generic Environment Variables |
| 86 | + |
| 87 | +For any Gluetun environment variable not covered by the typed methods: |
| 88 | + |
| 89 | +```csharp |
| 90 | +// String value |
| 91 | +vpn.WithGluetunEnvironment("DNS_ADDRESS", "1.1.1.1"); |
| 92 | + |
| 93 | +// Aspire parameter resource |
| 94 | +vpn.WithGluetunEnvironment("UPDATER_PERIOD", builder.AddParameter("updater-period")); |
| 95 | +``` |
| 96 | + |
| 97 | +This is useful for provider-specific settings. See the [Gluetun wiki](https://github.com/qdm12/gluetun-wiki) for the full list of environment variables. |
0 commit comments