mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
docs: start smoothing out proxy docs
This commit is contained in:
parent
f1601392e1
commit
dc7e93b618
@ -2,7 +2,7 @@
|
||||
title: How to run the Unleash Proxy
|
||||
---
|
||||
|
||||
The [Unleash Proxy](../sdks/unleash-proxy.md) provides a way for you to consume feature toggles in front-end clients, such as the [JavaScript Proxy client](../sdks/proxy-javascript.md) and [React Proxy client](../sdks/proxy-react.md).
|
||||
The [Unleash Proxy](../sdks/unleash-proxy.md) provides a way for you to consume feature toggles in [front-end clients](../sdks/index.md#front-end-sdks), such as the [JavaScript Proxy client](../sdks/proxy-javascript.md) and [React Proxy client](../sdks/proxy-react.md).
|
||||
|
||||
Depending on your setup, the Proxy is most easily run in one of two ways, depending on your situation:
|
||||
- Run the proxy via Docker
|
||||
@ -14,19 +14,22 @@ If you're using a hosted version of Unleash, we can also run the proxy for you i
|
||||
|
||||
This is what you need to do before you can run the proxy
|
||||
|
||||
- an unleash server to connect to
|
||||
- a client API token for the proxy to use
|
||||
- A running Unleash server to connect to
|
||||
- A client API token for the proxy to use.
|
||||
- if you're running the Proxy via Docker: [the `docker` command line tool](https://www.docker.com/)
|
||||
- If you're running the Proxy as a Node.js app: [Node.js and its command line tools](https://nodejs.org/).
|
||||
|
||||
## How to run the Proxy via Docker
|
||||
|
||||
The easiest way to run Unleash is via Docker. We have published a [docker image on docker hub](https://hub.docker.com/r/unleashorg/unleash-proxy).
|
||||
|
||||
1. **Pull the Proxy image**
|
||||
### 1. Pull the Proxy image
|
||||
|
||||
```bash
|
||||
docker pull unleashorg/unleash-proxy
|
||||
```
|
||||
|
||||
2. **Start the proxy**
|
||||
### 2. Start the proxy
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
@ -37,7 +40,7 @@ The easiest way to run Unleash is via Docker. We have published a [docker image
|
||||
unleashorg/unleash-proxy
|
||||
```
|
||||
|
||||
You should see the following output:
|
||||
You should see the following output:
|
||||
|
||||
```bash
|
||||
Unleash-proxy is listening on port 3000!
|
||||
@ -47,12 +50,16 @@ The easiest way to run Unleash is via Docker. We have published a [docker image
|
||||
|
||||
To run the Proxy via Node.js, you'll have to create your own Node.js project and use the Unleash Proxy as a dependency. Assuming you've already set up your project, here's the steps to take to start the proxy as part of your app:
|
||||
|
||||
1. **Install the Unleash Proxy package**
|
||||
### 1. Install the Unleash Proxy package
|
||||
|
||||
``` shell npm2yarn
|
||||
npm install @unleash/proxy
|
||||
```
|
||||
|
||||
2. **Initialize and start the proxy in your code.** A fully working sample app that uses the proxy:
|
||||
### 2. Initialize and start the proxy in your code.
|
||||
|
||||
A fully working sample app that uses the proxy:
|
||||
|
||||
``` js
|
||||
const port = 3000;
|
||||
|
||||
@ -78,24 +85,4 @@ In order to verify the proxy you can use curl and see that you get a few evaluat
|
||||
curl http://localhost:3000/proxy -H "Authorization: some-secret"
|
||||
```
|
||||
|
||||
The output is of the form described in the [payload section](#payload).
|
||||
|
||||
## Health endpoint
|
||||
|
||||
The proxy will try to synchronize with the Unleash API at startup, until it has successfully done that the proxy will return `HTTP 503 - Not Read?` for all request. You can use the health endpoint to validate that the proxy is ready to recieve requests:
|
||||
|
||||
```bash
|
||||
curl http://localhost:3000/proxy/health -I
|
||||
```
|
||||
|
||||
```bash
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Access-Control-Expose-Headers: ETag
|
||||
Content-Type: text/html; charset=utf-8
|
||||
Content-Length: 2
|
||||
ETag: W/"2-eoX0dku9ba8cNUXvu/DyeabcC+s"
|
||||
Date: Fri, 04 Jun 2021 10:38:27 GMT
|
||||
Connection: keep-alive
|
||||
Keep-Alive: timeout=5
|
||||
```
|
||||
Check the reference docs for API return values
|
||||
|
Loading…
Reference in New Issue
Block a user