A lightweight, type-safe proxy server built with TypeScript, Express, and Axios. This server acts as a middleware to proxy requests through a residential proxy service.
- TypeScript support with type safety
- Residential proxy integration
- HTML link rewriting for proxied content
- Automatic redirect handling
- Environment variable configuration
- Error handling and logging
- Test interface with iframe support
- Node.js (v14 or higher)
- npm (v6 or higher)
- A residential proxy service account
- Clone the repository:
git clone <repository-url>
cd proxy-server
- Install dependencies:
npm install
- Create a
.env
file in the root directory with your proxy configuration:
PROXY=username:password@host:port
PORT=3000 # Optional, defaults to 3000
Run the server in development mode with hot reloading:
npm run dev
- Build the TypeScript code:
npm run build
- Start the production server:
npm start
The server includes a test interface that allows you to easily test the proxy functionality:
- Start the server using one of the methods above
- Open your browser and navigate to
http://localhost:3000
- Enter a URL in the input field and click "Load URL"
- The proxied content will be displayed in an iframe
Proxies requests through the configured residential proxy.
Query Parameters:
url
(required): The target URL to proxy
Example:
http://localhost:3000/proxy?url=https://example.com
Variable | Description | Required | Default |
---|---|---|---|
PROXY | Proxy configuration in format username:password@host:port |
Yes | - |
PORT | Server port number | No | 3000 |
.
├── src/
│ └── index.ts # Main application file
├── public/
│ └── index.html # Test interface
├── dist/ # Compiled JavaScript files
├── .env # Environment variables
├── .gitignore # Git ignore file
├── package.json # Project dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # Project documentation
npm run dev
: Start development server with hot reloadingnpm run build
: Build TypeScript code to JavaScriptnpm start
: Run the production servernpm run watch
: Watch for TypeScript changes and rebuild
The server includes comprehensive error handling:
- Missing environment variables
- Invalid proxy configuration
- Network errors
- Invalid target URLs
- Proxy service errors
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the ISC License.