webhook icon indicating copy to clipboard operation
webhook copied to clipboard

forward request to another api endpoint

Open zewa666 opened this issue 3 years ago • 2 comments

hey there

i've a somewhat weird use case perhaps. I'm exposing an ipv6 service using a ddns services. Now since GitHub does not allow to enter ipv6 adresses for payload urls I did the following:

  • on a public cloud vps i've installed webhook using ipv4
  • added this target as new payload url in my github webhooks config
  • configured a command which executes a shell script with a curl replicating the github request and forwarding it to my ipv6 service
  • my service now can handle the webhook

while this is total overkill and a simple nginx reverse proxy config could have already solved my trouble it was nevertheless a fun experience to learn more about this app.

so much for the use cases, now the 2 issues I have. I'm not sure how to exactly mimic the request delegation with curl. do you have an example or is there perhaps already a built in reverse proxy feature? and secondly how can I make the command fail (non 200) if the curl request results in an error?

zewa666 avatar Jan 01 '22 21:01 zewa666

I'm not sure how to exactly mimic the request delegation with curl.

Me either.

is there perhaps already a built in reverse proxy feature?

No, and I'm not aware of any plans to add that.

how can I make the command fail (non 200) if the curl request results in an error?

You have to capture the exit code of the curl command and make sure your script exists with an error. For example, in bash:

curl --foobar
echo $?

moorereason avatar Jan 06 '22 23:01 moorereason

I think a simple SSH tunnel would be much more suitable for that use case, and probably a one-liner too. :-)

adnanh avatar Jan 16 '22 21:01 adnanh