Skip to content

About

Lightweight HTTP proxy server in Node.js

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

HTTP Proxy Server

Node.js Express License: ISC

This project configures an HTTP proxy server using Node.js, Express, and http-proxy. It is designed to forward requests from a frontend application to a backend API, manage CORS issues, and provide basic logging capabilities.

Getting Started

These instructions will guide you through setting up and running the project on your local machine for development and testing purposes.

Prerequisites

Ensure you have the following installed:

Installation

Follow these steps to set up your development environment:

  1. Clone the repository:
    git clone https://github.com/edrianolima/http_proxy_server
  2. Navigate to the repository directory:
    cd http_proxy_server
  3. Install the required packages:
    npm install

Configuration

Configure the server by updating the proxy settings:

  • Target API URL: Replace 'https://target-api.com' in the proxyTarget variable with your actual backend API URL.

  • Base Target Endpoint: Modify /base-target-endpoint/* in the route configuration to your backend base endpoint:

    const proxyTarget = 'https://target-api.com'; // Replace with your backend URL
    app.all('/base-target-endpoint/*', (req, res) => { // Replace with your backend Base target endpoint
        proxy.web(req, res, { target: proxyTarget, timeout: 60000 });
    });

Running the Server

To launch the server, execute:

npm start

Alternatively, for development with automatic restarts, you can use:

npm run dev

The server will initialize on port 4000, or another port if configured differently.

Health Check

Check the health of the proxy server by visiting:

http://localhost:4000/health

This will display the server uptime and a status message about the server's health.

Deployment

To deploy this proxy server using Docker, follow these steps:

  1. Build the Docker image:
    docker build -t http-proxy-server .
  2. Run the container:
    docker run -p 4000:4000 http-proxy-server

This will start the server in a Docker container and expose it on port 4000 of your host machine.

Technologies Used

Authors

License

This project is licensed under the ISC License - see the LICENSE file for details.

About

Lightweight HTTP proxy server in Node.js

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages