A simple HTTP server behaving as proxy between webhooks and Appwrite Functions.

Overview

Cover image

Appwrite Webhook Proxy

A simple HTTP server behaving as proxy between webhooks and Appwrite Functions, allowing for instance Stripe payments integration into Appwrite.

🚨 This is unofficial 3rd party exception for self-hosted Appwrite server 🚨

Maintained by core team member, tho 😛

Usage

  1. Make sure to have Appwrite function that can print APPWRITE_FUNCTION_DATA for you, so you can see it working. You can use appwrite-function.tar.gz from this repo as example function. Make sure to use NodeJS runtime, and set command to node index.js.

  2. Add webhook proxy container to Appwrite's docker stack. Locate docker-compose.yml file inside your appwrite folder, and add following section:

version: '3'

services:
  appwrite-webhook-proxy:
    image: meldiron/appwrite-webhook-proxy:v0.0.2
    container_name: appwrite-webhook-proxy
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.constraint-label-stack=appwrite"
      - "traefik.docker.network=appwrite"
      - "traefik.http.services.appwrite_webhook_proxy.loadbalancer.server.port=80"
      # http
      - traefik.http.routers.appwrite_webhook_proxy_http.entrypoints=appwrite_web
      - traefik.http.routers.appwrite_webhook_proxy_http.rule=PathPrefix(`/v1/webhook-proxy`)
      - traefik.http.routers.appwrite_webhook_proxy_http.service=appwrite_webhook_proxy
      # https
      - traefik.http.routers.appwrite_webhook_proxy_https.entrypoints=appwrite_websecure
      - traefik.http.routers.appwrite_webhook_proxy_https.rule=PathPrefix(`/v1/webhook-proxy`)
      - traefik.http.routers.appwrite_webhook_proxy_https.service=appwrite_webhook_proxy
      - traefik.http.routers.appwrite_webhook_proxy_https.tls=true
      - traefik.http.routers.appwrite_webhook_proxy_https.tls.certresolver=dns
    networks:
      - appwrite
    depends_on:
      - appwrite
    environment:
      - WEBHOOK_PROXY_APPWRITE_ENDPOINT
      - WEBHOOK_PROXY_APPWRITE_PROJECT_ID
      - WEBHOOK_PROXY_APPWRITE_API_KEY
      - WEBHOOK_PROXY_APPWRITE_FUNCTION_ID
  # ...
# ...
  1. Add webhook proxy configuration into Appwrite's stack. Locate hidden .env file inside your appwrite folder, and add following variables:
WEBHOOK_PROXY_APPWRITE_ENDPOINT=http://localhost/v1
WEBHOOK_PROXY_APPWRITE_PROJECT_ID=stripeTest
WEBHOOK_PROXY_APPWRITE_API_KEY=cb61e6bc3...abafcbb02
WEBHOOK_PROXY_APPWRITE_FUNCTION_ID=onStripeWebhook

Make sure to replace values with your credentials and information

  1. Restart Appwrite stack using docker-compose up -d

That's it! You can now visit http://localhost/v1/webhook-proxy (replace localhost with domain of Appwrite instance), and it will execute your function. You can see headers, endpoint, body, and pretty much all request information in the execution log, if you used our function tag from step 0.

Contribution

Setup:

docker run --rm --interactive --tty \
  --volume $PWD:/app \
  composer update --ignore-platform-reqs --optimize-autoloader --no-plugins --no-scripts --prefer-dist

Run local version:

docker-compose up --build --force-recreate

Use command above to also restart script after doing any changes.

Release version

  1. docker login
  2. docker build -t meldiron/appwrite-webhook-proxy:v0.0.2 .
  3. docker push meldiron/appwrite-webhook-proxy:v0.0.2

Make sure to change version number with releasing new version

You might also like...
Proxy Judge coded In PHP

Simple proxy judge created in PHP What is a Proxy Judge ? A ProxyJuge is usually a PHP script that returns a subset of the environment variables of th

This plugin allows you to create many-to-many relationships between pages in Kirby and synchronizes them on both sides.
This plugin allows you to create many-to-many relationships between pages in Kirby and synchronizes them on both sides.

Kirby 3 Many To Many Field This plugin allows you to create many-to-many relationships between pages in Kirby.

Manifest is a ProcessWire module that bridges between Twig and Webpack.

Manifest is a ProcessWire module that bridges between Twig and Webpack.

A fully-managed real-time messaging service that allows you to send and receive messages between independent applications.

A fully-managed real-time messaging service that allows you to send and receive messages between independent applications.

Prisma is an app that strengthens the relationship between people with memory loss and the people close to them

Prisma is an app that strengthens the relationship between people with memory loss and the people close to them. It does this by providing a living, collaborative digital photo album that can be populated with content of interest to these people.

A bot written in PHP which attempts to link IRC with SQL database, allowing for integration between platforms

Valeyard IRC-SQL-GateWay A bot written in PHP which attempts to link IRC with SQL database, allowing for integration between platforms. This bot is mo

Envbar allows you to differentiate between environments by adding a custom colored bar above the top navigation.
Envbar allows you to differentiate between environments by adding a custom colored bar above the top navigation.

Envbar Envbar allows you to differentiate between environments by adding a custom colored bar above the top navigation. This should help backend users

Library for check dependency between modules inside projects

PHP Dependency analyzer PHP DA is tool for check and support dependencies inside your project clear. For example: You have project with 3 root namespa

Share content between your websites.
Share content between your websites.

Distributor Distributor is a WordPress plugin that makes it easy to distribute and reuse content across your websites — whether in a single multisite

Comments
  • Getting An error

    Getting An error

    I am getting this error: manifest for meldiron/appwrite-webhook-proxy:v0.5 not found: manifest unknown: manifest unknown This comes up when I run docker-compose up -d A snippit of the docker-compose.yml:

    version: '3'
    
    services:
      appwrite-webhook-proxy:
        image: meldiron/appwrite-webhook-proxy:v0.5
        container_name: appwrite-webhook-proxy
        restart: unless-stopped
        labels:
          - "traefik.enable=true"
          - "traefik.constraint-label-stack=appwrite"
          - "traefik.docker.network=appwrite"
          - "traefik.http.services.appwrite_webhook_proxy.loadbalancer.server.port=4444"
          # http
          - traefik.http.routers.appwrite_webhook_proxy_http.entrypoints=appwrite_web
          - traefik.http.routers.appwrite_webhook_proxy_http.rule=PathPrefix(`/v1/webhook-proxy`)
          - traefik.http.routers.appwrite_webhook_proxy_http.service=appwrite_webhook_proxy
          # https
          - traefik.http.routers.appwrite_webhook_proxy_https.entrypoints=appwrite_websecure
          - traefik.http.routers.appwrite_webhook_proxy_https.rule=PathPrefix(`/v1/webhook-proxy`)
          - traefik.http.routers.appwrite_webhook_proxy_https.service=appwrite_webhook_proxy
          - traefik.http.routers.appwrite_webhook_proxy_https.tls=true
          - traefik.http.routers.appwrite_webhook_proxy_https.tls.certresolver=dns
        networks:
          - appwrite
        depends_on:
          - appwrite
        environment:
          - WEBHOOK_PROXY_APPWRITE_ENDPOINT
          - WEBHOOK_PROXY_APPWRITE_PROJECT_ID
          - WEBHOOK_PROXY_APPWRITE_API_KEY
          - WEBHOOK_PROXY_APPWRITE_FUNCTION_ID
      
      traefik:
    
    opened by rlee1990 1
  • No signatures found matching the expected signature for payload

    No signatures found matching the expected signature for payload

    Hello, I am using the example from here And the webhook function from the repository givent in the example.

    everything setup correctly but i got an error Error: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? https://github.com/stripe/stripe-node#webhook-signing

    From my webhook script, i confirm to you i am using the appwrite-webhook-proxy

    what can i do to fix my issue?

    opened by Francoisbeche 1
  • doesn't write an order into appwrite

    doesn't write an order into appwrite

    First of all thank you for this proxy!

    There are so many parts, I'll try to make it as clear as possible. I set everything according to your article. Everything is running on docker locally. Database Orders is populated with attributes and indexes through your script. I can directly reach this webhook-proxy server with postman at http://0.0.0.0:8079/v1/webhook-proxy

    When ordering, Stripe CLI (local proxy for webhooks) is connected with Stripe and send events to the proxy:

    2022-04-04 18:39:45   --> payment_intent.created [evt_3KkswPJ5qmHdQM1Gk2Wf3f]
    2022-04-04 18:39:45  <--  [201] POST http://0.0.0.0:8079/v1/webhook-proxy [evt_3KkswPJ5qmdQM1Gk2Wf3f]
    2022-04-04 18:40:17   --> customer.created [evt_1KkswuJ5qmHdQMyEWl6uxk]
    2022-04-04 18:40:17  <--  [201] POST http://0.0.0.0:8079/v1/webhook-proxy [evt_1KkswuJ5qmdQMyEWl6uxk]
    2022-04-04 18:40:17   --> payment_intent.succeeded [evt_3KkswPJ5qmHdQM1qfTZeVs]
    2022-04-04 18:40:17  <--  [201] POST http://0.0.0.0:8079/v1/webhook-proxy [evt_3KkswPJ5qmdQM1qfTZeVs]
    2022-04-04 18:40:17   --> charge.succeeded [evt_3KkswPJ5qmHdQM1yvzVRhL]
    2022-04-04 18:40:17  <--  [201] POST http://0.0.0.0:8079/v1/webhook-proxy [evt_3KkswPJ5qmQM1yvzVRhL]
    2022-04-04 18:40:17   --> checkout.session.completed [evt_1KkswvJ5qmHdQMUKRvGB9k]
    2022-04-04 18:40:17  <--  [201] POST http://0.0.0.0:8079/v1/webhook-proxy [evt_1KkswvJ5qmQMUKRvGB9k]
    

    (evt_ serials are modified)

    But no Order (Orders/Document) is added to the backend. The webhook-proxy logs (std output, no file found) doesn't show anything.

    Any idea? Would it be possible to add logs on this server to understand what it tries to do?

    opened by j2l 0
Releases(v0.0.5)
  • v0.0.5(Mar 11, 2022)

    What's Changed

    • Feat: Query params by @Meldiron in https://github.com/Meldiron/appwrite-webhook-proxy/pull/1

    New Contributors

    • @Meldiron made their first contribution in https://github.com/Meldiron/appwrite-webhook-proxy/pull/1

    Full Changelog: https://github.com/Meldiron/appwrite-webhook-proxy/compare/v0.0.4...v0.0.5

    Source code(tar.gz)
    Source code(zip)
  • v0.0.4(Mar 1, 2022)

  • v0.0.3(Mar 1, 2022)

  • v0.0.2(Jan 29, 2022)

    Full Changelog: https://github.com/Meldiron/appwrite-webhook-proxy/commits/v0.0.2

    We skipped v0.0.1 due to internal issues with Docker Hub.

    Source code(tar.gz)
    Source code(zip)
Owner
Matej Bačo
👋 Open-minded ​website developer.
Matej Bačo
Integrate your PHP application with your HTTP caching proxy

FOSHttpCache Introduction This library integrates your PHP applications with HTTP caching proxies such as Varnish. Use this library to send invalidati

FriendsOfSymfony 338 Dec 8, 2022
Profiles HTTP/SOCKS proxy(s) as multithreaded in seconds.

NextGen Proxy Profiler The scanner (proxyprof) scans and analyzes http/https/socks4/socks5 proxies quickly. It can complete thousands of proxy scans i

Özgür Koca 4 Nov 15, 2022
Paddle.com API integration for Laravel with support for webhooks/events

Laravel Paddle This package provides an integration with Paddle.com for Laravel. Read the blogpost about the introduction of the package! Features Sup

Protone Media 179 Dec 16, 2022
Organizr Plugin Equivilent of TehMuffinMoo/Throttling-Webhooks

Sonarr Throttling Organizr Plugin ❗ Important To add this plugin to Organizr, please add https://github.com/TehMuffinMoo/Organizr-Plugins to the Plugi

null 5 Jun 13, 2022
Paddle.com API integration for Laravel with support for webhooks/events

Laravel Paddle This package provides an integration with Paddle.com for Laravel. Read the blogpost about the introduction of the package! Features Sup

Protone Media 180 Jan 1, 2023
Magento-Functions - A Resource of Magento Functions

Magento-Functions A Resource of Magento Functions Table of Contents Category Product User Cart Checkout General Account [Working w/ URL's] (#urls) Cat

Bryan Littlefield 28 Apr 19, 2021
Here is the top 100 PHP functions: it is the list of the most often used PHP native functions

Here is the top 100 PHP functions: it is the list of the most often used PHP native functions. If you are a PHP developer, you must know the Top 100 PHP Functions deeply.

Max Base 16 Dec 11, 2022
Repman - PHP Repository Manager: packagist proxy and host for private packages

Repman - PHP Repository Manager Repman is a PHP repository manager. Main features: free and open source works as a proxy for packagist.org (speeds up

Repman 438 Jan 2, 2023
Proxy based Redis cluster solution supporting pipeline and scaling dynamically

Codis is a proxy based high performance Redis cluster solution written in Go. It is production-ready and widely used at wandoujia.com and many compani

null 12.7k Jan 2, 2023
Bitcoin Faucet integrated with banlist and VPN/Proxy Shield

Bitcoin Faucet integrated with banlist and VPN/Proxy Shield. It uses the service of Google reCaptcha (v2; box) and IPHub. Any claims will be saved in the account balance and can be withdrawn to ExpressCrypto, FaucetPay or directly using Block.io

null 2 Dec 18, 2022