---
title: Proxy
project: Total.js V5
version: 0.0.20
section: guides
language: en
license: MIT
url: https://totaljs.es/docs/total-js-v5/0-0-20/guides/proxy/
updated: 2026-11-16T16:36:31.083Z
---

# Proxy

> Forward requests with PROXY(), and publish an app of a private network through a public Total.js app with PROXYSERVER() and PROXYCLIENT().

`PROXY(path, target)` forwards requests to another HTTP server or a Unix socket. It is part of the routing and described in [Routing](../routing/#proxies).

### Publishing a local app through a public server

`PROXYSERVER()` and `PROXYCLIENT()` make an app running on your computer (or in a private network) reachable through a public Total.js app. The public app runs the server part, the private machine runs the client part, and the two talk over one binary WebSocket that the client opens. Every HTTP request that arrives at the server is sent through the WebSocket to the client, the client calls the local app and sends the response back.

```js
// The public app
PROXYSERVER('/', '/$proxy/');
```

```js
// The private machine (any Total.js app, or a small script)
PROXYCLIENT('https://public.example.com/$proxy/', '127.0.0.1:8000');
```

`PROXYSERVER(endpoint, socketendpoint)` forwards all requests that start with `endpoint` and listens for the client at `socketendpoint`. Only one client can be connected; until it connects, requests get `400` with `Not yet available.`. The local request gets the header `x-proxy: Total.js` and the `host` of the local app. When the request to the local app fails (the app does not run or closes the connection), the visitor gets an empty response with the status `200`. Both functions write their activity to the console; pass your own function as the last argument to log elsewhere.
