Software & Apps

GitHub – janbjorge/pipegate

PipeGate is a lightweight, self-hosted proxy built with FastAPI, designed as a “poor man’s hook.” It allows you to expose your local servers to the internet, providing a simple way to create tunnels from your local machine to the outside world. PipeGate is an excellent tool for developers who want to understand how tunneling services like ngrok work under the hood or need a customizable alternative hosted on their own infrastructure.

  • Self-hosted: Deploy PipeGate on your own infrastructure, giving you control over your setup.
  • Unique Connections: Clients connect using unique UUIDs, which ensure that each tunnel is unique.
  • Customizable: Modify and extend PipeGate to fit your specific needs.
  • Lightweight: Small dependencies and straightforward setup make it easy to use.
  • Education: A great tool for learning how tunneling services work internally.

Before you begin, make sure you meet the following requirements:

First, clone the PipeGate repository to your local machine:

git clone https://github.com/janbjorge/pipegate.git
cd pipegate

You can also install PipeGate directly from GitHub using pip:

pip install git+https://github.com/janbjorge/pipegate.git

Deploy the PipeGate server in your infrastructure. By default, the server is running http://0.0.0.0:8000.

python -m pipegate.server

Optional: To adjust the host and port, change the uvicorn.run parameters of server.py or create environment variables when executed.

Run the PipeGate client on your local machine to expose a local server.

python -m pipegate.client --port 8000 --server_url wss://yourserver.com/<connection_id>

Parameters:

  • --port: Port where your local server is running (eg 8000).
  • --server_url: WebSocket URL to your PipeGate server, including the unique connection ID.

For example:

python -m pipegate.client --port 8000 --server_url wss://example.com/123e4567-e89b-12d3-a456-426614174000
  1. Starting the Server:

    python -m pipegate.server
  2. Getting Started with the Client:

    python -m pipegate.client --port 8000 --server_url wss://yourserver.com/<connection_id>

    change with a generated UUID to establish a unique tunnel.

  3. Reveal Local Server:

    Point your external webhook or services to https://yourserver.com//pathand PipeGate will forward the requests to your local server running on the port 8000.

Public Server (Temporary)

For demonstration purposes, a PipeGate server is currently running on https://pipegate.fly.dev/. Feel free to use this server to test PipeGate functionality. This server will remain available until Fly.io credits are used up. 🤷‍♂️

Example of Using Public Server:

  1. Getting Started with the Client:

    python -m pipegate.client --port 8000 --server_url wss://pipegate.fly.dev/123e4567-e89b-12d3-a456-426614174000

    change 123e4567-e89b-12d3-a456-426614174000 with a generated UUID.

  2. Reveal Local Server:

    Point your external webhook or services to https://pipegate.fly.dev/123e4567-e89b-12d3-a456-426614174000/pathand PipeGate will forward the requests to your local server running on the port 8000.

Note: The public server of https://pipegate.fly.dev/ intended for temporary use only. Users are encouraged to set up their own PipeGate server for continuous and secure tunneling.

PipeGate is highly customizable. You can change the server and client configurations to adapt the tool to your specific needs. See the source code and documentation for detailed configuration options.

Possible Configuration Improvements:

  • Verification: Implement API keys or tokens to manage client connections.
  • Timeouts: Adjust request and connection timeouts based on your needs.
  • Logging in: Configure logging levels and outputs to monitor activity.

Note: Future releases may include configuration files or environment variable support for easier customization.

PipeGate have little or no built-in security features. It is important to implement your own security measures to protect your infrastructure when using PipeGate. Consider the following:

  • Verification: Ensure that only authorized clients can connect to your PipeGate server by implementing authentication mechanisms such as API keys or tokens.
  • Network Security: Use firewalls, VPNs, or other network security tools to prevent access to your PipeGate server.
  • Input Verification: Apply full validation and filtering to incoming requests to prevent malicious activity.
  • Encryption: Consider setting up HTTPS to encrypt data in transit, especially when sending sensitive information.
  • Monitoring and Auditing: Regularly monitor and audit your PipeGate setup to identify and address potential threats.
  • Resource Limits: Implement rate limiting or throttling to prevent abuse and ensure fair use of server resources.

Disclaimer: PipeGate is provided “as is” without warranty. Use it at your own risk.

Contributions are welcome! Whether you’re fixing bugs, improving documentation, or adding new features, your help is appreciated.

  1. Fork the Repository: Click the “Fork” button on the top right of the repository page.

  2. Clone your fork:

    git clone https://github.com/janbjorge/pipegate.git
    cd pipegate
  3. Create a New Branch:

    git checkout -b feature/YourFeatureName
  4. Make Your Changes: Implement your feature or fix.

  5. Submit Your Changes:

    git commit -m "Add your message here"
  6. Push on your fork:

    git push origin feature/YourFeatureName
  7. Open a Pull Request: Go to the original repository and make a pull request.

This project is licensed under the MY License.

For any questions or suggestions, do not open an issue.

Q: How do I create a unique connection ID?

A: You can use Python’s uuid module or any UUID generator to generate a unique ID.

Q: Can I run multiple clients with the same server?

A: Yes, each client must use a unique connection ID to establish separate tunnels.


https://opengraph.githubassets.com/c90d15b68ce429bab6a4b998b907c396ab1a6861ee4623423eb8e37d9c220306/janbjorge/pipegate

2024-12-17 18:09:06

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button