### Quick Start Docker Compose Setup Source: https://github.com/openziti/zrok/blob/main/docker/compose/zrok2-instance/README.md Use this command to copy the example environment file and then edit it with your specific configurations before starting the Docker Compose services. ```bash cp .env.example .env # Edit .env — set ZROK2_DNS_ZONE, ZROK2_ADMIN_TOKEN, and ZITI_PWD docker compose up -d ``` -------------------------------- ### Copy Example Environment File Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/docker.mdx Copy the example environment file to start configuring your zrok2 deployment. ```bash cp .env.example .env ``` -------------------------------- ### Run http-server Example Source: https://github.com/openziti/zrok/blob/main/sdk/nodejs/README.md Share a public HTTP server using zrok. This example starts an Express server and prints the frontend endpoint. ```bash cd examples/http-server npm install npm run build node dist/index.js http-server ``` -------------------------------- ### Install zrok Agent with Repository Setup Source: https://github.com/openziti/zrok/blob/main/website/docs/how-tos/_linux-agent-install.mdx Run this one-liner to set up the zrok package repository and install the agent packages simultaneously. Ensure you have curl installed. ```bash curl -sSLf https://get.openziti.io/install.bash \ | sudo bash -s zrok2-agent ``` -------------------------------- ### Install zrok Python Client via Setuptools Source: https://github.com/openziti/zrok/blob/main/sdk/python/src/README.md Install the zrok Python package using Setuptools. Use `--user` for local installation or `sudo` for system-wide installation. ```sh python setup.py install --user ``` -------------------------------- ### Build zrok Documentation Website Source: https://github.com/openziti/zrok/blob/main/BUILD.md Install dependencies and start a development server for the zrok documentation website using Yarn. For production builds, use 'yarn build'. ```bash cd website yarn install # usually only needed once yarn start # development server on port 3000 ``` -------------------------------- ### Run pastebin Example (Serve Text) Source: https://github.com/openziti/zrok/blob/main/sdk/nodejs/README.md Share text privately using zrok's TCP tunnel. This command starts the 'copyto' service. ```bash cd examples/pastebin npm install npm run build # terminal 1: serve text node dist/index.js copyto ``` -------------------------------- ### Enable and Start Services Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/linux.mdx Enables and starts the RabbitMQ, PostgreSQL, and InfluxDB services on system boot. ```bash sudo systemctl enable --now rabbitmq-server postgresql influxdb ``` -------------------------------- ### Initialize InfluxDB Setup Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/linux.mdx Runs the InfluxDB initial setup to create an organization, bucket, admin token, and set retention policy. ```bash influx setup \ --org zrok \ --bucket zrok \ --username admin \ --password "$(head -c24 /dev/urandom | base64 -w0)" \ --token "" \ --retention 0 \ --force ``` -------------------------------- ### Start Local Development Server Source: https://github.com/openziti/zrok/blob/main/website/README.md Starts a local development server for live previewing changes. The server automatically reloads when modifications are made. ```bash $ yarn start ``` -------------------------------- ### Start Dynamic Proxy Frontend Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/dynamic-proxy.md Run the dynamicProxy frontend using the specified configuration file. This command initiates the connection to the Ziti network, subscribes to AMQP, and starts serving traffic. ```bash zrok2 access dynamicProxy etc/dynamicProxy.yml ``` -------------------------------- ### Start Public Frontend with Configuration Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/error-pages.md Start the public frontend service using the `zrok2 access public` command with the path to your frontend configuration YAML file. ```bash zrok2 access public /path/to/frontend-config.yml ``` -------------------------------- ### Enable and Start zrok Frontend Service Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/linux.mdx Enables the zrok frontend service to start automatically on boot and starts it immediately. This command ensures the frontend is running and accessible. ```bash sudo systemctl enable --now zrok2-frontend ``` -------------------------------- ### Enable and start zrok agent service Source: https://github.com/openziti/zrok/blob/main/website/docs/how-tos/agent/setup-linux-service.mdx Enable the zrok agent service to start automatically on login and start it immediately. ```bash systemctl --user enable --now zrok2-agent.service ``` -------------------------------- ### zrok version output Source: https://github.com/openziti/zrok/blob/main/website/docs/how-tos/install/macos.mdx Example output of the `zrok2 version` command, showing the installed version. ```text _ _____ __ ___ | | __ |_ / '__/ _ \| |/ / / /| | | (_) | < /___|_| \___/|_|\_ v2.0.0 [c889005] ``` -------------------------------- ### Enable and Start zrok Controller Service Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/linux.mdx Enables the zrok2-controller service to start automatically on boot and starts it immediately. ```bash sudo systemctl enable --now zrok2-controller ``` -------------------------------- ### Install RabbitMQ on Ubuntu/Debian Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/dynamic-proxy.md Install and enable the RabbitMQ server on Ubuntu or Debian-based systems. ```bash sudo apt-get install rabbitmq-server sudo systemctl enable rabbitmq-server sudo systemctl start rabbitmq-server ``` -------------------------------- ### Install zrok2 executable to ~/bin Source: https://github.com/openziti/zrok/blob/main/website/docs/how-tos/install/linux.mdx Installs the zrok2 executable to the user's local bin directory. This is a step in the manual binary installation. ```bash mkdir -p ~/bin && install /tmp/zrok2/zrok2 ~/bin/ ``` -------------------------------- ### Example HTML for Static Website Source: https://github.com/openziti/zrok/blob/main/website/docs/how-tos/shares/share-websites-and-files.md This is an example of an index.html file that zrok will serve as a static website. ```html

Hello zrok

``` -------------------------------- ### Test Dynamic Proxy Setup Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/dynamic-proxy.md Verify the dynamicProxy setup by creating a test share. This involves enabling the zrok environment, setting a default namespace, creating a reserved name, and sharing a resource. ```bash # First, enable a zrok environment if you haven't already zrok2 enable # Set the default namespace for convenience zrok2 config set defaultNamespace # Create a reserved name in the namespace zrok2 create name -n my-test-share # Share a resource using the reserved name zrok2 share public --backend-mode web -n :my-test-share ~/public ``` -------------------------------- ### Python Remote Share Example Source: https://github.com/openziti/zrok/blob/main/sdk/python/src/docs/AgentApi.md Shows how to initiate a remote share using the AgentApi. This example requires API key authentication and proper client configuration. ```python import zrok_api from zrok_api.models.remote_share200_response import RemoteShare200Response from zrok_api.models.remote_share_request import RemoteShareRequest from zrok_api.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to /api/v2 # See configuration.py for a list of all supported configuration parameters. configuration = zrok_api.Configuration( host = "/api/v2" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: key configuration.api_key['key'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['key'] = 'Bearer' # Enter a context with an instance of the API client with zrok_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = zrok_api.AgentApi(api_client) body = zrok_api.RemoteShareRequest() # RemoteShareRequest | (optional) try: api_response = api_instance.remote_share(body=body) print("The response of AgentApi->remote_share:\n") pprint(api_response) except Exception as e: print("Exception when calling AgentApi->remote_share: %s\n" % e) ``` -------------------------------- ### Install zrok Helm Chart Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/kubernetes.mdx Install the zrok Helm chart into a dedicated namespace. This command installs the chart, creates the namespace if it doesn't exist, and sets the Ziti admin password. ```bash helm install zrok2 openziti/zrok2 \ --namespace zrok2 --create-namespace \ --values my-values.yaml \ --set ziti.password="your-ziti-admin-password" ``` -------------------------------- ### Install zrok2 Node.js SDK Source: https://github.com/openziti/zrok/blob/main/sdk/nodejs/README.md Install the zrok2 Node.js SDK using npm. ```bash npm install @openziti/zrok2 ``` -------------------------------- ### Install zrok2 using the install script Source: https://github.com/openziti/zrok/blob/main/website/docs/how-tos/install/linux.mdx A bash script that automatically detects the CPU architecture, downloads the latest zrok2 release, and installs it to /usr/local/bin/. Requires sudo privileges. ```bash cd $(mktemp -d); ZROK_VERSION=( curl -sSf https://api.github.com/repos/openziti/zrok/releases/latest \ | jq -r '.tag_name' ); case $(uname -m) in x86_64) GOXARCH=amd64 ;; aarch64|arm64) GOXARCH=arm64 ;; arm*) GOXARCH=armv7 ;; *) echo "ERROR: unknown arch '$(uname -m)'" >&2 exit 1 ;; esac; curl -sSfL \ "https://github.com/openziti/zrok/releases/download/${ZROK_VERSION}/zrok2_${ZROK_VERSION#v}_linux_${GOXARCH}.tar.gz" \ | tar -xz -f -; sudo install -o root -g root ./zrok2 /usr/local/bin/; zrok2 version; ``` -------------------------------- ### Enable and Start Zrok Frontend Service Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/linux.mdx Enable and start the zrok2-frontend systemd service for production deployments. Assumes frontend configuration is complete. ```bash sudo systemctl enable --now zrok2-frontend ``` ```bash sudo journalctl -u zrok2-frontend -f ``` -------------------------------- ### Install RabbitMQ and PostgreSQL on RHEL/Fedora Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/linux.mdx Installs RabbitMQ and PostgreSQL server packages on RHEL-based systems and initializes the PostgreSQL database. ```bash sudo dnf install rabbitmq-server postgresql-server sudo postgresql-setup --initdb # RHEL/Fedora only ``` -------------------------------- ### Install SDK with Test Extras Source: https://github.com/openziti/zrok/blob/main/sdk/python/README.md Create a virtual environment and install the SDK in editable mode with test extras. This includes the SDK, its runtime dependencies, pytest, and pytest-cov. ```bash python3 -m venv .venv source .venv/bin/activate pip install -e src/[test] ``` -------------------------------- ### Build and Start zrok with Additional Compose Files Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/docker.mdx Builds and starts zrok services using multiple compose files, including custom configurations for Caddy. Ensure your .env file is updated with your values. ```bash COMPOSE_FILE=compose.yml:compose.build.yml:compose.caddy.yml \ docker compose up -d --build --wait ``` -------------------------------- ### Install RabbitMQ on RHEL/CentOS/Fedora Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/dynamic-proxy.md Install and enable the RabbitMQ server on RHEL, CentOS, or Fedora systems. ```bash sudo dnf install rabbitmq-server sudo systemctl enable rabbitmq-server sudo systemctl start rabbitmq-server ``` -------------------------------- ### Start zrok Metrics Bridge Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/metrics-and-limits/configure-metrics.md Start the zrok metrics bridge process, pointing it to your zrok controller configuration file. ```bash zrok2 controller metrics bridge ``` -------------------------------- ### Enable and Start Zrok Controller Service Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/linux.mdx Enable and start the zrok2-controller systemd service for production deployments. Assumes controller configuration is complete. ```bash sudo systemctl enable --now zrok2-controller ``` ```bash sudo journalctl -u zrok2-controller -f ``` -------------------------------- ### Install Full Test Requirements Source: https://github.com/openziti/zrok/blob/main/sdk/python/README.md Install all test requirements, including linters like flake8 and mypy, and tox for more comprehensive testing. ```bash pip install -r src/test-requirements.txt ``` -------------------------------- ### Share Model Usage Example Source: https://github.com/openziti/zrok/blob/main/sdk/python/src/docs/Share.md Example demonstrating how to use the Share model in Python, including creating instances from JSON and dictionaries, and converting them back. ```APIDOC ## Share Model Usage Example ### Example ```python from zrok_api.models.share import Share # TODO update the JSON string below json = "{}" # create an instance of Share from a JSON string share_instance = Share.from_json(json) # print the JSON string representation of the object print(Share.to_json()) # convert the object into a dict share_dict = share_instance.to_dict() # create an instance of Share from a dict share_from_dict = Share.from_dict(share_dict) ``` ``` -------------------------------- ### Python Configuration Model Example Source: https://github.com/openziti/zrok/blob/main/sdk/python/src/docs/Configuration.md Demonstrates creating a Configuration instance from a JSON string, converting it to JSON, and converting it to and from a dictionary. Ensure the JSON string is valid. ```python from zrok_api.models.configuration import Configuration # TODO update the JSON string below json = "{}" # create an instance of Configuration from a JSON string configuration_instance = Configuration.from_json(json) # print the JSON string representation of the object print(Configuration.to_json()) # convert the object into a dict configuration_dict = configuration_instance.to_dict() # create an instance of Configuration from a dict configuration_from_dict = Configuration.from_dict(configuration_dict) ``` -------------------------------- ### Get Version Information Source: https://github.com/openziti/zrok/blob/main/sdk/python/src/docs/MetadataApi.md Retrieve the version information for the zrok API. This example shows basic setup for API client configuration. ```python import zrok_api from zrok_api.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to /api/v2 ``` -------------------------------- ### Start zrok stack with Caddy overlay Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/docker.mdx Starts the zrok stack using both the main compose file and the Caddy overlay compose file. Caddy will handle TLS termination. ```bash COMPOSE_FILE=compose.yml:compose.caddy.yml docker compose up -d ``` -------------------------------- ### Install zrok2 Packages on Debian/Ubuntu Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/linux.mdx Installs the zrok2 controller, frontend, and metrics bridge packages using apt. Ensure you have followed the Linux installation guide. ```bash sudo apt install zrok2 zrok2-controller zrok2-frontend zrok2-metrics-bridge ``` -------------------------------- ### Start zrok agent service Source: https://github.com/openziti/zrok/blob/main/website/docs/how-tos/agent/windows-service/index.mdx Start the 'zrokAgent' Windows service. This command can be used after interactive or non-interactive installation. ```cmd C:\Program Files\zrok2>sc start zrokAgent ``` -------------------------------- ### Install zrok Cards Source: https://github.com/openziti/zrok/blob/main/website/docs/how-tos/install/_install_cards.mdx Renders download cards for different operating systems. Each card links to specific installation guides. ```jsx import { AssetsProvider } from '@zrokroot/src/components/assets-context'; import DownloadCard from '@zrokroot/src/components/download-card'; import DownloadCardStyles from '@zrokroot/src/css/download-card.module.css'; import useBaseUrl from '@docusaurus/useBaseUrl';
``` -------------------------------- ### Install RabbitMQ with Docker Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/dynamic-proxy.md Use this Docker command to quickly set up a RabbitMQ instance for testing the dynamic proxy. ```bash docker run -d --name rabbitmq \ -p 5672:5672 \ -p 15672:15672 \ rabbitmq:3-management ``` -------------------------------- ### Install Python Requirements for zrok SDK Source: https://github.com/openziti/zrok/blob/main/sdk/python/examples/pastebin/README.md Installs the necessary Python libraries for the zrok SDK examples. Ensure you have Python 3.10 or later. ```bash pip install -r ./sdk/python/examples/pastebin/requirements.txt ``` -------------------------------- ### Ansible playbook to set up package repository and install zrok2 Source: https://github.com/openziti/zrok/blob/main/website/docs/how-tos/install/linux.mdx An Ansible playbook to automate the setup of the zrok2 package repository and installation of the zrok2 package. This is useful for managing multiple hosts. ```yaml - name: Install zrok2 package gather_facts: false hosts: all become: true tasks: - name: Install zrok2 ansible.builtin.package: name: zrok2 state: present ``` -------------------------------- ### Delete Identity using Admin API Source: https://github.com/openziti/zrok/blob/main/sdk/python/src/docs/AdminApi.md This example demonstrates deleting an identity through the Admin API. It requires API key authentication and proper client setup. ```python import zrok_api from zrok_api.models.delete_identity_request import DeleteIdentityRequest from zrok_api.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to /api/v2 # See configuration.py for a list of all supported configuration parameters. configuration = zrok_api.Configuration( host = "/api/v2" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: key configuration.api_key['key'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed ``` -------------------------------- ### Initialize Ziti Controller Source: https://github.com/openziti/zrok/blob/main/website/docs/_attic/network/prod/zrok.io-network-skeleton.md Initialize the ziti controller with its configuration file. ```bash $ ~/local/ziti/ziti-controller edge init local/etc/zrok.io/ziti-ctrl.yml ``` -------------------------------- ### Quick Start: Build zrok2 Source: https://github.com/openziti/zrok/blob/main/docker/images/cross-build/README.md Use this script for a quick build of zrok2. It automatically detects the host architecture, builds the necessary container image on first run, and requires only Docker. ```bash bin/build.bash # quiet mode bin/build.bash --verbose # show full build output ``` -------------------------------- ### Python SDK: ProxyShare helper class for HTTP reverse proxy Source: https://context7.com/openziti/zrok/llms.txt The `ProxyShare.create()` helper class manages share lifecycle and starts an HTTP reverse proxy. It forwards traffic to a local API using the `requests` library, simplifying proxy setup. ```python from zrok2.proxy import ProxyShare import zrok2.environment root = zrok2.environment.loadRoot() proxy = ProxyShare.create( root=root, target="http://localhost:9000", # upstream to proxy share_mode="public", unique_name="my-persistent-proxy", # reuse across restarts verify_ssl=True, ) print("Access at:", ", ".join(proxy.endpoints or [])) # Blocks; ctrl-c to stop proxy.run() ``` -------------------------------- ### Invite User Source: https://github.com/openziti/zrok/blob/main/sdk/python/src/docs/AccountApi.md This example shows how to invite a new user to the system. No authorization is required for this operation. ```python import zrok_api from zrok_api.models.invite_request import InviteRequest from zrok_api.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to /api/v2 # See configuration.py for a list of all supported configuration parameters. configuration = zrok_api.Configuration( host = "/api/v2" ) # Enter a context with an instance of the API client with zrok_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = zrok_api.AccountApi(api_client) body = zrok_api.InviteRequest() # InviteRequest | (optional) try: api_instance.invite(body=body) except Exception as e: print("Exception when calling AccountApi->invite: %s\n" % e) ``` -------------------------------- ### Verify zrok2 installation Source: https://github.com/openziti/zrok/blob/main/website/docs/how-tos/install/linux.mdx Verifies the zrok2 installation by checking its version. This command should be run after installing zrok2. ```bash zrok2 version ``` -------------------------------- ### Get Help for Creating an Organization Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/organizations.md Use this command to see the available flags and usage for creating a new organization. ```bash zrok2 admin create organization --help ``` -------------------------------- ### Run zrok Proxy Example Source: https://github.com/openziti/zrok/blob/main/sdk/python/examples/proxy/README.md Execute the proxy script with a specified target URL. Ensure the LOG_LEVEL is set to INFO for detailed output. ```bash LOG_LEVEL=INFO python ./proxy.py http://127.0.0.1:3000 ``` -------------------------------- ### Create and Use a Publisher Source: https://github.com/openziti/zrok/blob/main/sdk/golang/pubsub/README.md Configure and create a publisher to send messages. Ensure the identity path is correctly set. ```go package main import ( "context" "fmt" "github.com/openziti/zrok/v2/sdk/golang/pubsub" "github.com/sirupsen/logrus" ) func main() { // configure the publisher cfg := &pubsub.PublisherConfig{ ServiceName: "zrok-pubsub-service", IdentityPath: "/path/to/publisher.json", } // create publisher pub, err := pubsub.NewPublisher(cfg) if err != nil { dl.Fatalf("failed to create publisher: %v", err) } defer pub.Close() // publish dynamic hostname mapping msg := pubsub.NewMessage("hostname_update", "frontend", map[string]any{ "operation": "ADD", "hostname": "api.example.com", "service": "zrok-service-abc123", "ttl": 3600, }) ctx := context.Background() if err := pub.Publish(ctx, msg); err != nil { dl.Errorf("failed to publish: %v", err) } fmt.Println("message published successfully") } ``` -------------------------------- ### Install Dependencies Source: https://github.com/openziti/zrok/blob/main/website/README.md Installs project dependencies using Yarn. ```bash $ yarn ``` -------------------------------- ### Python Example: CreateFrontend201Response Source: https://github.com/openziti/zrok/blob/main/sdk/python/src/docs/CreateFrontend201Response.md Demonstrates how to create an instance of CreateFrontend201Response from a JSON string, convert it to a dictionary, and create it from a dictionary. Ensure the JSON string is valid. ```python from zrok_api.models.create_frontend201_response import CreateFrontend201Response # TODO update the JSON string below json = "{}" # create an instance of CreateFrontend201Response from a JSON string create_frontend201_response_instance = CreateFrontend201Response.from_json(json) # print the JSON string representation of the object print(CreateFrontend201Response.to_json()) # convert the object into a dict create_frontend201_response_dict = create_frontend201_response_instance.to_dict() # create an instance of CreateFrontend201Response from a dict create_frontend201_response_from_dict = CreateFrontend201Response.from_dict(create_frontend201_response_dict) ``` -------------------------------- ### Create Frontend with Admin API Source: https://github.com/openziti/zrok/blob/main/sdk/python/src/docs/AdminApi.md Shows how to create a frontend service using the Admin API with API key authentication. The API key must be configured via the API_KEY environment variable. ```python import zrok_api from zrok_api.models.create_frontend201_response import CreateFrontend201Response from zrok_api.models.create_frontend_request import CreateFrontendRequest from zrok_api.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to /api/v2 # See configuration.py for a list of all supported configuration parameters. configuration = zrok_api.Configuration( host = "/api/v2" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: key configuration.api_key['key'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['key'] = 'Bearer' # Enter a context with an instance of the API client with zrok_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = zrok_api.AdminApi(api_client) body = zrok_api.CreateFrontendRequest() # CreateFrontendRequest | (optional) try: api_response = api_instance.create_frontend(body=body) print("The response of AdminApi->create_frontend:\n") pprint(api_response) except Exception as e: print("Exception when calling AdminApi->create_frontend: %s\n" % e) ``` -------------------------------- ### Start the zrok Agent Source: https://github.com/openziti/zrok/blob/main/website/docs/how-tos/agent/manage-shares.mdx Start the zrok agent in the foreground. This is a prerequisite for managing shares. ```bash zrok2 agent start ``` -------------------------------- ### Enable zrok Client Environment Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/kubernetes.mdx Configure your local zrok CLI to point to your deployed zrok instance and enable your client environment using the obtained token. ```bash export ZROK2_API_ENDPOINT=https://zrok2.share.example.com zrok2 enable ``` -------------------------------- ### List All Names using Python Source: https://github.com/openziti/zrok/blob/main/sdk/python/src/docs/ShareApi.md This example demonstrates how to list all available share names. It requires API key authentication and handles potential exceptions during the API call. ```python import zrok_api from zrok_api.models.name import Name from zrok_api.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to /api/v2 # See configuration.py for a list of all supported configuration parameters. configuration = zrok_api.Configuration( host = "/api/v2" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: key configuration.api_key['key'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['key'] = 'Bearer' # Enter a context with an instance of the API client with zrok_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = zrok_api.ShareApi(api_client) try: api_response = api_instance.list_all_names() print("The response of ShareApi->list_all_names:\n") pprint(api_response) except Exception as e: print("Exception when calling ShareApi->list_all_names: %s\n" % e) ``` -------------------------------- ### Install RabbitMQ and PostgreSQL on Debian/Ubuntu Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/linux.mdx Installs RabbitMQ and PostgreSQL server packages on Debian-based systems. ```bash sudo apt install rabbitmq-server postgresql ``` -------------------------------- ### Go SDK: Private Share Server (Pastebin Pattern) Source: https://context7.com/openziti/zrok/llms.txt Sets up a listener on a private share to accept multiple inbound connections, serving each in a goroutine. Data is piped in via stdin. ```go package main import ( "fmt" "io" "net" "os" "github.com/openziti/zrok/v2/environment" "github.com/openziti/zrok/v2/sdk/golang/sdk" ) func main() { data, _ := io.ReadAll(os.Stdin) // pipe data in via stdin root, _ := environment.LoadRoot() shr, err := sdk.CreateShare(root, &sdk.ShareRequest{ BackendMode: sdk.TcpTunnelBackendMode, ShareMode: sdk.PrivateShareMode, Target: "pastebin", }) if err != nil { panic(err) } defer sdk.DeleteShare(root, shr) fmt.Printf("access your pastebin using 'pastefrom %v'\n", shr.Token) listener, _ := sdk.NewListener(shr.Token, root) for { conn, err := listener.Accept() if err != nil { break } go func(c net.Conn) { defer c.Close() c.Write(data) }(conn) } } ``` -------------------------------- ### Run zrok Pastebin Server (copyto) Source: https://github.com/openziti/zrok/blob/main/sdk/python/examples/pastebin/README.md Starts the zrok pastebin server, accepting data from standard input. The output will provide a share token to access the data. ```bash echo "this is a cool test" | python pastebin.py copyto ``` -------------------------------- ### Bootstrap OpenZiti Network for zrok Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/linux.mdx Initializes the OpenZiti network for zrok by creating the necessary database, Ziti identities, and policies. ```bash zrok2 admin bootstrap /etc/zrok2/ctrl.yml ``` -------------------------------- ### Import zrok Python Client after pip install Source: https://github.com/openziti/zrok/blob/main/sdk/python/src/README.md Import the zrok_api package into your Python script after installation. ```python import zrok_api ``` -------------------------------- ### sdk.Overview Source: https://context7.com/openziti/zrok/llms.txt Returns a JSON snapshot of all environments and shares attached to the account. Useful for monitoring and dashboards. ```APIDOC ## sdk.Overview Returns a JSON snapshot of all environments and shares attached to the account. Useful for monitoring and dashboards. ### Description Retrieves a JSON snapshot of all environments and associated shares for the account, ideal for monitoring and dashboarding purposes. ### Usage ```go package main import ( "fmt" "github.com/openziti/zrok/v2/environment" "github.com/openziti/zrok/v2/sdk/golang/sdk" ) func main() { root, _ := environment.LoadRoot() json, err := sdk.Overview(root) if err != nil { panic(err) } // json contains: {"environments":[{"environment":{...},"shares":[...]}]} fmt.Println(json) } ``` ``` -------------------------------- ### Start and Enable Metrics Bridge Service Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/deployment/linux.mdx Enable and start the zrok2-metrics-bridge systemd service to process metrics. ```bash sudo systemctl enable --now zrok2-metrics-bridge ``` -------------------------------- ### Okta Issuer URL Example Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/oauth/integrations/oidc.md Example of an issuer URL for Okta. Replace 'your-domain.okta.com' with your Okta domain. ```yaml issuer: "https://your-domain.okta.com/oauth2/default" ``` -------------------------------- ### Complete Dynamic Proxy Configuration (YAML) Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/dynamic-proxy.md A comprehensive example of the dynamicProxy configuration file, demonstrating all available options including frontend identification, refresh intervals, AMQP subscribers, controller clients, TLS, interstitial pages, and OAuth providers. ```yaml v: 1 # Frontend identification frontend_token: KMmfE0VXO7Pp identity: public bind_address: "0.0.0.0:8080" # Mapping refresh interval mapping_refresh_interval: 1m # AMQP subscriber for receiving mapping updates amqp_subscriber: url: amqp://guest:guest@localhost:5672 exchange_name: dynamicProxy queue_depth: 1024 # Optional: buffer size for mapping updates (default: 1024) # Controller client for gRPC queries controller: identity_path: /home/zrok/.zrok2/identities/public.json service_name: dynamicProxyController timeout: 30s # Optional: gRPC request timeout (default: 30s) # Optional: TLS configuration for HTTPS tls: cert_path: /etc/letsencrypt/live/zrok.example.com/fullchain.pem key_path: /etc/letsencrypt/live/zrok.example.com/privkey.pem # Optional: Interstitial page configuration interstitial: enabled: true html_path: /etc/zrok/interstitial.html user_agent_prefixes: - "Mozilla/" - "Chrome/" # Optional: OAuth configuration oauth: bind_address: "127.0.0.1:8181" endpoint_url: "https://oauth.zrok.example.com:8443" cookie_name: "zrok-auth-session" cookie_domain: "zrok.example.com" max_cookie_chunks: 10 # Optional: maximum cookie stripes to accept or emit (default: 10) session_lifetime: "6h" intermediate_lifetime: "5m" signing_key: "your-32-plus-character-signing-key-here" encryption_key: "your-24-plus-character-encryption-key-here" max_cookie_size: 3072 # Optional: maximum cookie size in bytes (default: 3072) providers: # Google OAuth - name: "google" type: "google" client_id: "your-google-client-id" client_secret: "your-google-client-secret" # GitHub OAuth - name: "github" type: "github" client_id: "your-github-client-id" client_secret: "your-github-client-secret" # Generic OIDC - name: "microsoft" type: "oidc" client_id: "your-oidc-client-id" client_secret: "your-oidc-client-secret" scopes: ["openid", "email", "profile"] issuer: "https://login.microsoftonline.com//v2.0" supports_pkce: true ``` -------------------------------- ### Auth0 Issuer URL Example Source: https://github.com/openziti/zrok/blob/main/website/docs/self-hosting/oauth/integrations/oidc.md Example of an issuer URL for Auth0. Replace 'your-domain.auth0.com' with your Auth0 domain. ```yaml issuer: "https://your-domain.auth0.com/" ``` -------------------------------- ### Install Zrok Source: https://github.com/openziti/zrok/blob/main/sdk/python/examples/proxy/proxy.ipynb Install the zrok Python package using pip. This is the first step before using any zrok functionalities. ```python ! pip install zrok ``` -------------------------------- ### Go SDK: Get Overview Source: https://context7.com/openziti/zrok/llms.txt Retrieves a JSON snapshot of all environments and shares associated with the account. Useful for monitoring and dashboarding purposes. ```go package main import ( "fmt" "github.com/openziti/zrok/v2/environment" "github.com/openziti/zrok/v2/sdk/golang/sdk" ) func main() { root, _ := environment.LoadRoot() json, err := sdk.Overview(root) if err != nil { panic(err) } // json contains: {"environments":[{"environment":{...},"shares":[...]}]} fmt.Println(json) } ``` -------------------------------- ### CreateFrontendRequest Usage Example Source: https://github.com/openziti/zrok/blob/main/sdk/python/src/docs/CreateFrontendRequest.md Example of how to use the CreateFrontendRequest model in Python, including instantiation from JSON and conversion to a dictionary. ```APIDOC ## Example ```python from zrok_api.models.create_frontend_request import CreateFrontendRequest # TODO update the JSON string below json = "{}" # create an instance of CreateFrontendRequest from a JSON string create_frontend_request_instance = CreateFrontendRequest.from_json(json) # print the JSON string representation of the object print(CreateFrontendRequest.to_json()) # convert the object into a dict create_frontend_request_dict = create_frontend_request_instance.to_dict() # create an instance of CreateFrontendRequest from a dict create_frontend_request_from_dict = CreateFrontendRequest.from_dict(create_frontend_request_dict) ``` ``` -------------------------------- ### Install zrok2 using curl Source: https://github.com/openziti/zrok/blob/main/website/docs/how-tos/install/linux.mdx Installs the zrok2 package using a curl command. This is the recommended method for most Linux users. ```bash curl -sSf https://get.openziti.io/install.bash | sudo bash -s zrok2 ```