Skip to content

Commit

Permalink
chore: spell out "system proxy" and update the docs
Browse files Browse the repository at this point in the history
ctron committed Feb 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent d8fa1d2 commit 056c415
Showing 5 changed files with 18 additions and 8 deletions.
8 changes: 8 additions & 0 deletions Trunk.toml
Original file line number Diff line number Diff line change
@@ -94,6 +94,14 @@ backend = "http://localhost:9000/api/v2/"
backend = "https://localhost:9000/api/v3/"
insecure = true

[[proxy]]
# This proxy example has the no_system_proxy field. In this example,
# connections to https://172.16.0.1:9000/api/v3/ will bypass the system proxy.
# This may be useful in cases where a local system has a proxy configured which cannot be reconfigured, but the
# proxy target (of trunk serve) is not know/accessible by the system's proxy.
backend = "https://172.16.0.1:9000/api/v3/"
no_system_prox = true

## hooks
# Hooks are optional, and default to `None`.
# Hooks are executed as part of Trunk's main build pipeline, no matter how it is run.
2 changes: 2 additions & 0 deletions site/content/configuration.md
Original file line number Diff line number Diff line change
@@ -29,6 +29,8 @@ The `trunk serve` command accepts two proxy related flags.

`--proxy-insecure` allows the `--proxy-backend` url to use a self signed certificate for https (or any officially [invalid](https://docs.rs/reqwest/latest/reqwest/struct.ClientBuilder.html#method.danger_accept_invalid_certs) certs, including expired). This would be used when proxying to https such as `trunk serve --proxy-backend=https://localhost:3001/ --proxy-insecure` where the ssl cert was self signed, such as with [mkcert](https://github.com/FiloSottile/mkcert), and routed through an https reverse proxy for the backend, such as [local-ssl-proxy](https://github.com/cameronhunter/local-ssl-proxy) or [caddy](https://caddyserver.com/docs/quick-starts/reverse-proxy).

`--proxy-no-sytem-proxy` bypasses the system proxy when contacting the proxy backend.

`--proxy-ws` specifies that the proxy is for a WebSocket endpoint.

## Config File
12 changes: 6 additions & 6 deletions src/config/models/mod.rs
Original file line number Diff line number Diff line change
@@ -248,9 +248,9 @@ pub struct ConfigOptsServe {
#[serde(default)]
pub proxy_insecure: bool,
/// Configure the proxy to bypass system proxy [default: false]
#[arg(long = "proxy-no-sys-proxy")]
#[arg(long = "proxy-no-system-proxy")]
#[serde(default)]
pub proxy_no_sys_proxy: bool,
pub proxy_no_system_proxy: bool,
/// Disable auto-reload of the web app [default: false]
#[arg(long = "no-autoreload")]
#[serde(default)]
@@ -326,10 +326,10 @@ pub struct ConfigOptsProxy {
/// Configure the proxy to accept insecure certificates.
#[serde(default)]
pub insecure: bool,
/// Configure the proxy to bypass system proxy
#[serde(rename = "no-sys-proxy")]
/// Configure the proxy to bypass the system proxy. Defaults to `false`.
#[serde(rename = "no-system-proxy")]
#[serde(default)]
pub no_sys_proxy: bool,
pub no_system_proxy: bool,
}

/// Config options for build system hooks.
@@ -513,7 +513,7 @@ impl ConfigOpts {
ws_protocol: cli.ws_protocol,
tls_key_path: cli.tls_key_path,
tls_cert_path: cli.tls_cert_path,
proxy_no_sys_proxy: cli.proxy_no_sys_proxy,
proxy_no_system_proxy: cli.proxy_no_system_proxy,
};
let cfg = ConfigOpts {
build: None,
2 changes: 1 addition & 1 deletion src/config/rt.rs
Original file line number Diff line number Diff line change
@@ -348,7 +348,7 @@ impl RtcServe {
proxy_backend: opts.proxy_backend,
proxy_rewrite: opts.proxy_rewrite,
proxy_insecure: opts.proxy_insecure,
proxy_no_sys_proxy: opts.proxy_no_sys_proxy,
proxy_no_sys_proxy: opts.proxy_no_system_proxy,
proxy_ws: opts.proxy_ws,
proxies,
no_autoreload: opts.no_autoreload,
2 changes: 1 addition & 1 deletion src/serve.rs
Original file line number Diff line number Diff line change
@@ -343,7 +343,7 @@ fn router(state: Arc<State>, cfg: Arc<RtcServe>) -> Result<Router> {
proxy.rewrite.clone(),
ProxyClientOptions {
insecure: proxy.insecure,
no_system_proxy: proxy.no_sys_proxy,
no_system_proxy: proxy.no_system_proxy,
},
)?;
}

0 comments on commit 056c415

Please sign in to comment.