Skip to content

IP-Information Capture client details: IP, user-agent, and location. lightweight Node.js

Notifications You must be signed in to change notification settings

WhoisGray/ip-information

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌐 IP Information

A simple Node.js application that captures client request details and provides information about the client, including IP address, user agent, and geo location.

DockerHub

🚀 Quick Start

  1. Clone the repository:

    git clone https://github.com/WhoisGray/ip-information.git
  2. Install dependencies:

    npm install
  3. Start the server:

    npm start
  4. Open your browser and navigate to http://localhost:3000.

🚀 Usage

Pull the Docker Image

docker pull WhoisGray/ip-information:latest

Run the Docker Container

docker run -p 3000:3000 WhoisGray/ip-information:latest

Open your browser and navigate to http://localhost:3000 to access the application.

🐳 Docker Compose

If you prefer to use Docker Compose, you can use the following docker-compose.yml file:

version: "3"
services:
  ip-information:
    image: whoisgray/ip-information:latest
    ports:
      - 3000:3000

Save this content in a file named docker-compose.yml in your project directory, and then run the following command:

  docker-compose up

This will start the IP Information application in a Docker container.

🐳 Docker

This project includes Docker and Docker Compose files, allowing you to easily containerize and run the application in a Docker environment. To use Docker, follow these steps:

  1. Install Docker on your machine.
  2. Build the Docker image:
    docker build -t ip-information .
  3. Run the Docker container:
    docker run -p 3000:3000 ip-information
  4. Open your browser and navigate to http://localhost:3000.

📋 Features

  • Express - Fast, unopinionated, minimalist web framework for Node.js.
  • geoip-lite - Lightweight module to look up IP address information.

Routes

The application defines the following routes:

  • Root Route ("/")

    • This route handles GET requests to the root URL ("/").
    • It retrieves the client's public IP address and sends it as a response to the client.
    • The IP address is extracted from the request headers, specifically the "x-forwarded-for" header or the remote address.
    • The IP address is displayed as a response message, indicating the client's public IP address.
  • "/details" Route

    • This route handles GET requests to the "/details" URL.
    • It retrieves additional information about the client, including IP address, user agent, and geo-location.
    • The IP address is extracted from the request headers, similar to the root route.
    • The user-agent information is obtained from the "user-agent" header in the request.
    • The geoLocation information is obtained using the "geoip-lite" package based on the client's IP address.
    • The response is a JSON object containing the client's IP address, user agent, and geo-location details, along with other request information like URL, method, headers, and cookies.

You can access the root route ("/") to retrieve the client's public IP address and the "/details" route to obtain more comprehensive client information.

Feel free to modify or add more routes based on your application's requirements.

📝 License

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

👤 Author: