← 返回命令列表

Linux command

rocky 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Forward

rocky --port [8080] --forward [http://server:9000]

Forward selected routes

rocky --port [8080] --forward [http://server] --route "[/api/*, /images/*]"

Replay traffic

rocky --port [8080] --forward [http://primary] --replay [http://shadow]

Load balance

rocky --port [8080] --balance "[http://a:9000, http://b:9000]"

Run from a TOML config file

rocky --config [path/to/rocky.toml]

Serve over HTTPS

rocky --port [8443] --key [server.key] --cert [server.crt] --forward [http://backend]

说明

rocky is a middleware-oriented HTTP and WebSocket reverse proxy built on Node.js. The rocky-cli front-end exposes its core features through a single command so a proxy can be started without writing JavaScript. It can forward requests to one or more backends, replay traffic to shadow services, balance load across upstreams, and intercept or transform requests and responses on the fly. Routes are expressed as glob patterns and matched against the request path, letting you proxy only specific endpoints while ignoring others. Replay targets receive a copy of each forwarded request, which is useful for blue/green deployments, regression testing against a new backend, or recording traffic for later analysis. Configuration can be passed entirely on the command line or loaded from a TOML file via --config, making it easy to commit reproducible proxy setups alongside the rest of a project.

参数

-c _file_, --config _file_
Load configuration from a TOML file.
-p _port_, --port _port_
TCP port for the local HTTP server.
-f _url_, --forward _url_
Default upstream URL to forward traffic to.
-r _url_, --replay _url_
Additional upstream that receives a copy of every request (replay/shadow target). Repeatable.
-t _routes_, --route _routes_
Comma-separated list of route patterns to handle. Glob-style wildcards are supported.
-b _urls_, --balance _urls_
Comma-separated list of upstream URLs to balance traffic between.
-k _file_, --key _file_
Path to the SSL/TLS private key.
-e _file_, --cert _file_
Path to the SSL/TLS certificate.
-s, --secure
Enable strict SSL certificate validation when proxying to HTTPS upstreams.
-m, --mute
Disable HTTP traffic logging.
-d, --debug
Enable verbose debug output.
-v, --version
Print the version and exit.
-h, --help
Show usage help.

FAQ

What is the rocky command used for?

rocky is a middleware-oriented HTTP and WebSocket reverse proxy built on Node.js. The rocky-cli front-end exposes its core features through a single command so a proxy can be started without writing JavaScript. It can forward requests to one or more backends, replay traffic to shadow services, balance load across upstreams, and intercept or transform requests and responses on the fly. Routes are expressed as glob patterns and matched against the request path, letting you proxy only specific endpoints while ignoring others. Replay targets receive a copy of each forwarded request, which is useful for blue/green deployments, regression testing against a new backend, or recording traffic for later analysis. Configuration can be passed entirely on the command line or loaded from a TOML file via --config, making it easy to commit reproducible proxy setups alongside the rest of a project.

How do I run a basic rocky example?

Run `rocky --port [8080] --forward [http://server:9000]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -c _file_, --config _file_ do in rocky?

Load configuration from a TOML file.