68 lines
2.7 KiB
Markdown
68 lines
2.7 KiB
Markdown
|
|
# 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 (`libssl` and `libcrypto`)
|
||
|
|
- SQLite3 library
|
||
|
|
|
||
|
|
### Installation
|
||
|
|
1. Clone the repository:
|
||
|
|
```bash
|
||
|
|
git clone <repository-url>
|
||
|
|
cd <repository-directory>
|
||
|
|
```
|
||
|
|
2. Build the project using the Makefile:
|
||
|
|
```bash
|
||
|
|
make
|
||
|
|
```
|
||
|
|
3. Run the server:
|
||
|
|
```bash
|
||
|
|
make run
|
||
|
|
```
|
||
|
|
|
||
|
|
### Configuration
|
||
|
|
|
||
|
|
The configuration for RProxy is stored in the `proxy_config.json` file. Below is a breakdown of its structure:
|
||
|
|
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"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.json` file.
|
||
|
|
- **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](LICENSE) file for details.
|