Skip to content

Repository files navigation

🧭 HTTP Proxy Server

English | PortuguΓͺs

A robust and configurable HTTP proxy server developed in TypeScript, featuring authentication, host access control, and logging. Ideal for scenarios such as Discord bots, data scraping, and traffic control.

πŸš€ Features

  • πŸ” Basic authentication via config.toml
  • 🌐 Host access control
  • πŸ“„ Logging with Winston
  • βš™οΈ All configuration is loaded exclusively from config.toml
  • πŸ§ͺ Modular and extensible structure

Note:
All configuration is centralized in the config.toml file and loaded through the src/config/ module. No environment variables or other config files are used.

πŸ“¦ Installation

  1. Clone the repository:

    git clone https://github.com/HCDevWorks/http-proxy.git
    cd http-proxy
  2. Install the dependencies:

    pnpm install
  3. Configure the config.toml file (see config.example.toml for an example):

    [server]
    port = 8888
    
    [logging]
    enableLogs = true
    enableErrorLogs = false
    
    [auth]
    username = "your_username"
    password = "your_password"
    
    [allowed_hosts]
    hosts = ["google.com", "youtube.com"]
    # Or to allow all hosts:
    # hosts = "*"

Note:
To allow connections from any host, set hosts = "*" in [allowed_hosts].
To restrict, use a list of domains, like hosts = ["google.com", "youtube.com"].

πŸ› οΈ Usage

Start the proxy server with:

pnpm build # build the server

pnpm start # start the server

The server will listen on the port defined in config.toml (default: 8888).

πŸ–₯️ Running as a Linux Service

See how to create a systemd service to run the proxy automatically on Linux in docs/LINUX-SERVICE.md.

πŸ“ Project Structure

http-proxy/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ index.ts      # Loads and exports the validated config object
β”‚   β”‚   β”œβ”€β”€ loader.ts     # Loads and parses config.toml, validates with Zod
β”‚   β”‚   └── schema.ts     # Zod schema and types for config
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ logger.ts     # Winston logger configuration
β”‚   β”‚   └── server.ts     # Main proxy server logic
β”‚   └── index.ts          # Entry point
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ testProxy.ts
β”‚   └── testProxyBenchmark.ts
β”œβ”€β”€ config.toml
β”œβ”€β”€ config.example.toml
β”œβ”€β”€ logs/
β”‚   └── proxy.log
β”œβ”€β”€ package.json
β”œβ”€β”€ pnpm-lock.yaml
β”œβ”€β”€ tsconfig.json
└── docs/
    β”œβ”€β”€ LINUX-SERVICE.md
    └── pt-br/
        β”œβ”€β”€ LINUX-SERVICE.md
        └── README.md

🀝 Contributing

Contributions are welcome! Please read our Code of Conduct and Contributing Guidelines before opening issues or pull requests.

We also provide templates to help you:

πŸ“„ License

This project is licensed under the MIT License.

About

Advanced HTTP/HTTPS proxy server in TypeScript, built on proxy-chain. Features configurable authentication, strict host validation, keep-alive connections, response compression, and advanced logging with Winston. Ideal for Discord bots, web scraping, and secure web traffic control.

Topics

Resources

Code of conduct

Contributing

Stars

8 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages