06287f323d2b81e0501c8cd042b165bd224d3636
Implement additional statistical metrics collection within the existing working module, including new counters for processing time and throughput. The changes extend the stats reporting functionality to capture more granular performance data without altering core logic.
RProxy
RProxy is a reverse proxy server designed to route requests to various upstream services based on the hostname. It is built using C and leverages the cJSON library for JSON parsing. This README provides a comprehensive guide on how to get started, configure the server, and understand its features.
Getting Started
Prerequisites
- GCC (GNU Compiler Collection)
- Make
- OpenSSL libraries (
libsslandlibcrypto) - SQLite3 library
Installation
- Clone the repository:
git clone <repository-url> cd <repository-directory> - Build the project using the Makefile:
make - Run the server:
make run
Configuration
The configuration for RProxy is stored in the proxy_config.json file. Below is a breakdown of its structure:
{
"port": 8585,
"reverse_proxy": [
{ "hostname": "example.com", "upstream_host": "127.0.0.1", "upstream_port": 3000, "use_ssl": false }
]
}
- port: The port on which the RProxy server will listen for incoming requests.
- reverse_proxy: An array of objects, each representing a reverse proxy configuration.
- hostname: The hostname that the server will respond to.
- upstream_host: The IP address or hostname of the upstream service.
- upstream_port: The port on which the upstream service is running.
- use_ssl: A boolean indicating whether to use SSL for the upstream connection.
Features
- Reverse Proxying: RProxy can route requests to multiple upstream services based on the hostname.
- SSL Support: Optionally, RProxy can connect to upstream services using SSL.
- Dynamic Configuration: The configuration can be easily modified by editing the
proxy_config.jsonfile. - Multi-Host Support: RProxy can handle requests for multiple hostnames, making it suitable for microservices architectures.
Use Cases
- Microservices Architecture: RProxy can be used to route requests to different microservices based on the hostname, simplifying service discovery.
- Load Balancing: By configuring multiple upstream services for a single hostname, RProxy can distribute traffic among them.
- API Gateway: RProxy can serve as an API gateway, providing a single entry point for various backend services.
Monitoring and Statistics
RProxy can be extended to monitor various statistics such as:
- Request Count: The total number of requests handled by the server.
- Response Times: The time taken to respond to requests.
- Error Rates: The number of failed requests to upstream services.
License
Copyright (c) retoor. All rights reserved.
This project is licensed under the MIT License - see the LICENSE file for details.
Languages
C
98.6%
Makefile
1.4%