Skip to main content

Installation

note

Before installing Lunar's Proxy, make sure that Docker is installed on your environment. If you haven't installed Docker yet, you can learn more about it and download it from the Docker website


Step 1: Pull Lunar's Proxy Image​

To begin the installation process, you need to pull the latest version of Lunar's proxy image.
ΦΏOpen a terminal or command prompt and execute the following command:

docker pull lunarapi/lunar-proxy:v0.8.15

This command will download the latest version of the proxy image from the Docker Hub repository.

Step 2: Create your local Configuration File​

The policies.yaml file in the Lunar Proxy serves as the central configuration hub, allowing users to define various policies and configurations for the Lunar Proxy system.

Run the following commands for creating an empty policies.yaml file. Don't worry, you will edit it in the next steps.

touch policies.yaml
tip

For more information about how to customize the policies.yaml file please visit the Customize page.

Step 3: Run Lunar's Proxy Container​

Once the image download is complete, you can run the proxy container using the following command:

docker run -d --rm -p 8000:8000 -p 8040:8040 -e TENANT_NAME="ORGANIZATION" -v $(pwd):/etc/lunar-proxy --name lunar-proxy lunarapi/lunar-proxy:v0.8.15
caution

Note that the TENANT_NAME environment variable is required. This variable should be set to the name of your organization.

Docker command break down

-d: Start a container in detached mode.

--rm: Automatically remove the container when it exits.

-p: Publish all exposed ports to the host interfaces.

-e: Set environment variables. In this case, we set the TENANT_NAME environment variable to ORGANIZATION.

-v: Flag in your Docker run command to mount your local policies.yaml file to the /etc/lunar-proxy directory inside the Lunar Proxy container.

--name: The UUID identifiers come from the Docker daemon.

Step 4: Verify Installation​

To ensure the successful installation of Lunar Proxy there are two options:

Option 1: Run the following command to make a request to the healthcheck endpoint which validates that Lunar Proxy is up.

curl http://localhost:8040/healthcheck

Option 2: Try to pass a request through the proxy by running the following command:

curl http://localhost:8000/fact -H "Host: catfact.ninja" -H "X-Lunar-Scheme: https"

This will make a request to Lunar Proxy on port 8000, which will forward the request to the upstream server catfact.ninja on port 443, at the path /fact (this is an API that returns the latest exchange rates).

The result should look something like this:

{"fact":"Among many other diseases, cats can suffer from anorexia, senility, feline AIDS and acne.","length":89}

Then, use the Discover command to validate that the requests were passed through Lunar Proxy.

docker exec lunar-proxy discover

The result should look something like this:

{
"interceptors": [
{
"type": "unknown",
"version": "unknown",
"last_transaction_date": "2023-07-10T08:56:12Z"
}
],
"endpoints": {
"GET:::catfact.ninja/fact": {
"min_time": "2023-02-05T17:07:42",
"max_time": "2023-02-05T17:09:14",
"count": 1,
"status_codes": {
"200": 1
},
"average_duration": 555
}
}
}
note

The interceptor type and version are unknown because we are using curl to make the request. Once an interceptor is used, its type and version will appear in the discover command output.

For more information about the Discover command, see Discover.

Click me for guidance πŸ˜€