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.
You can run the provider proxy server easily using the Docker image. Follow the below steps to run the container.
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 .
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
.
If you'd prefer to run the server manually from the source code, follow these steps:
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
Ensure you have Node.js installed. Install the required dependencies:
npm install
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
Start the server by running:
npm run start
The server will now be running on http://localhost:3040
.
-
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
To verify if the server is running, use the following endpoint:
- GET /health
curl http://localhost:3040/health
Expected response: OK
(HTTP 200)
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.