Configuration
VPN Provider
Section titled “VPN Provider”Every Gluetun setup requires a VPN service provider:
var vpn = builder.AddGluetun("vpn") .WithVpnProvider("mullvad");See the Gluetun wiki for the full list of supported providers.
VPN Protocol
Section titled “VPN Protocol”WireGuard
Section titled “WireGuard”// String key (for development/testing)vpn.WithWireGuard("my-private-key");
// Aspire parameter resource (recommended for secrets)vpn.WithWireGuard(builder.AddParameter("wireguard-key", secret: true));Sets VPN_TYPE=wireguard and WIREGUARD_PRIVATE_KEY.
OpenVPN
Section titled “OpenVPN”// String credentials (for development/testing)vpn.WithOpenVpn("username", "password");
// Aspire parameter resources (recommended for secrets)vpn.WithOpenVpn( builder.AddParameter("openvpn-user"), builder.AddParameter("openvpn-pass", secret: true));Sets VPN_TYPE=openvpn, OPENVPN_USER, and OPENVPN_PASSWORD.
Server Selection
Section titled “Server Selection”vpn.WithServerCountries("US", "Canada", "Germany");vpn.WithServerCities("New York", "Toronto");Values are comma-joined and set as SERVER_COUNTRIES / SERVER_CITIES environment variables.
Proxy Features
Section titled “Proxy Features”Gluetun includes built-in HTTP and Shadowsocks proxies:
vpn.WithHttpProxy(); // HTTPPROXY=onvpn.WithHttpProxy(false); // HTTPPROXY=offvpn.WithShadowsocks(); // SHADOWSOCKS=onvpn.WithShadowsocks(false); // SHADOWSOCKS=offTo expose the proxy ports, pass them when creating the resource:
var vpn = builder.AddGluetun("vpn", httpProxyPort: 8888, shadowsocksPort: 8388) .WithHttpProxy() .WithShadowsocks();Network & Firewall
Section titled “Network & Firewall”vpn.WithFirewallOutboundSubnets("10.0.0.0/8", "192.168.0.0/16");vpn.WithTimezone("America/New_York");WithFirewallOutboundSubnets sets FIREWALL_OUTBOUND_SUBNETS, useful for allowing traffic to local network resources outside the VPN tunnel.
Generic Environment Variables
Section titled “Generic Environment Variables”For any Gluetun environment variable not covered by the typed methods:
// String valuevpn.WithGluetunEnvironment("DNS_ADDRESS", "1.1.1.1");
// Aspire parameter resourcevpn.WithGluetunEnvironment("UPDATER_PERIOD", builder.AddParameter("updater-period"));This is useful for provider-specific settings. See the Gluetun wiki for the full list of environment variables.