I'm running an Jenkins instance inside my private network at home. This instance polls (hourly) various repositories at github for changes and acts on those changes.
To reduce load both on my network and on github, I would like to implement webhooks, but don't feel too happy about opening up my Jenkins installation to the internet, or even to the specific few IP addresses from where I can expect webhook calls.
Is there a kind of proxy which I could install on a sacrificial host which forwards the request to the real server inside my network? Call parameter sanitation would be a nice extra.
Step 1: go to your GitHub repository and click on 'Settings'. Step 2: Click on Webhooks and then click on 'Add webhook'. Step 3: In the 'Payload URL' field, paste your Jenkins environment URL. At the end of this URL add /github-webhook/.
You can configure the proxy server that Jenkins will use by going to Manage Jenkins > Manage Plugins > Advanced. This is preferred over setting JVM properties. If the proxy server requires authentication, enter the name of the user here. If the proxy server requires authentication, enter the password here.
Manual Mode. icon (under Manage Jenkins > Configure System > GitHub) to see the URL in Jenkins that receives the post-commit POSTs — but in general the URL is of the form $JENKINS_BASE_URL/github-webhook/ — for example: https://ci.example.com/jenkins/github-webhook/ .
We have a similar setup, where we have one internet-exposed host which receives webhooks from our various git providers, does some rewriting if necessary, and then forwards the hook internally to Jenkins (or wherever).
This is done with a very simple nginx config:
# Allow *only* the notifyCommit endpoint, and don't expose any other info
location = /git/notifyCommit {
proxy_pass http://jenkins.int.example.com:8080/git/notifyCommit
proxy_hide_header X-Powered-By;
proxy_intercept_errors on;
error_page 500 /;
}
The use of the location =
syntax, means that only that exact URL (plus query parameters) is matched. Everything else will throw a 404 error.
Alternatively, you could try running git-webhook-proxy on an exposed host; it's a webserver I created that will intercept webhooks and then cache the repositories locally before forwarding the webhooks via the internal network to Jenkins.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With