# rproxy rproxy is a high-performance reverse proxy server written in C. It routes HTTP and WebSocket requests to upstream services based on hostname, with support for SSL/TLS termination and connection pooling. ## Features - Reverse proxy routing by hostname - SSL/TLS support for upstream connections - WebSocket proxying - Connection pooling and idle timeout management - Real-time monitoring and statistics - Web-based dashboard for metrics visualization - SQLite-based persistent statistics storage - Epoll-based event handling for high concurrency ## Dependencies - GCC - OpenSSL (libssl, libcrypto) - SQLite3 - cJSON library ## Build ```bash make ``` This compiles the source files in `src/` and produces the `rproxy` executable. ## Configuration Configuration is defined in `proxy_config.json`: ```json { "port": 9998, "reverse_proxy": [ { "hostname": "example.com", "upstream_host": "127.0.0.1", "upstream_port": 5000, "use_ssl": false, "rewrite_host": true } ] } ``` - `port`: Listening port for incoming connections - `reverse_proxy`: Array of routing rules - `hostname`: Host header to match for routing - `upstream_host`: Target server hostname/IP - `upstream_port`: Target server port - `use_ssl`: Enable SSL for upstream connection - `rewrite_host`: Rewrite Host header to upstream hostname ## Usage ```bash ./rproxy [config_file] ``` If no config file is specified, defaults to `proxy_config.json`. ## Endpoints - Dashboard: `http://localhost:{port}/rproxy/dashboard` - API Stats: `http://localhost:{port}/rproxy/api/stats` ## Architecture - **main.c**: Entry point, event loop, signal handling - **connection.c**: Connection management, epoll handling - **http.c**: HTTP request/response parsing - **ssl_handler.c**: SSL/TLS connection handling - **monitor.c**: System and per-vhost statistics collection - **dashboard.c**: Web dashboard generation - **config.c**: JSON configuration parsing - **buffer.c**: Circular buffer implementation - **logging.c**: Logging utilities ## Testing ```bash make test ``` Runs unit tests for core components.