Skip to content

Latest commit

 

History

History
112 lines (68 loc) · 2.69 KB

README.md

File metadata and controls

112 lines (68 loc) · 2.69 KB

Provider Proxy Server

This proxy server acts as an intermediary for fetching data related to your deployment from the Spheron Provider. The server handles both HTTP and WebSocket requests to communicate with the Spheron provider. You can either run the server using a Docker image or set it up manually using the source code in this repository.

Table of Contents

  1. Option 1: Use the Docker Image
  2. Option 2: Run from Source Code
  3. Environment Variables
  4. Health Check

Option 1: Use the Docker Image

You can run the provider proxy server easily using the Docker image. Follow the below steps to run the container.

1. Pull the Docker Image

Pull the Docker image from Docker Hub using the following command:

docker pull spheronnetwork/provider-proxy-server:latest

Or build the image from the source code:

docker build -t spheronnetwork/provider-proxy-server:latest .

2. Run the Docker Container

Run the container, mapping port 3040 to your local machine:

docker run -p 3040:3040 spheronnetwork/provider-proxy-server:latest

This will start the server, and it will be accessible on http://localhost:3040.

Option 2: Run from Source Code

If you'd prefer to run the server manually from the source code, follow these steps:

1. Clone the Repository

Clone the repository containing the provider-proxy-server:

git clone https://github.com/spheronFdn/protocol-sdk.git

Navigate to the provider-proxy-server directory:

cd ./provider-proxy-server

2. Install Dependencies

Ensure you have Node.js installed. Install the required dependencies:

npm install

3. Set Environment Variables

Create a .env file or set the environment variables directly. The default port is 3040. You can change the port by modifying the .env file:

PORT=3040

4. Start the Server

Start the server by running:

npm run start

The server will now be running on http://localhost:3040.

Environment Variables

  • PORT: The port on which the server will run (default: 3040).

    To use a custom port, set the PORT environment variable before running the container or server.

Example:

PORT=3040

Health Check

To verify if the server is running, use the following endpoint:

  • GET /health
curl http://localhost:3040/health

Expected response: OK (HTTP 200)

CORS Policy

The server allows requests from all origins (*). This is useful when running the server locally. In production, you should restrict the origins to only the domains you trust.