github-plugin icon indicating copy to clipboard operation
github-plugin copied to clipboard

[JENKINS-66079] Override Hook URL check throws 411 error when using a reverse proxy

Open jenkins-infra-bot opened this issue 4 years ago • 4 comments

We want to place our Jenkins behind IAP, hence exposing webhooks in a different nginx reverse proxy. When trying to override the webhook in Jenkins settings, I am getting a 411 error.

 

Override Hook URL
   Specify another hook URL for GitHub configuration

https://mywebhookurl.mydomain.com/github-webhook/

 Got 411 from https://mywebhookurl.mydomain.com/github-webhook/

 

Nginx config is pretty straight forward:

 

server {
 server_name mywebhookurl.mydomain.com;
 access_log logs/access.log;
 error_log logs/error.log;
 listen 80;
 include ssl_settings.conf;
 ignore_invalid_headers off;
 chunked_transfer_encoding on;
 location / {
 proxy_pass http://instance-url.internal-domain:8080/;
 proxy_set_header Host $host:$server_port;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-Proto $scheme;
 proxy_set_header X-Forwarded-Host $host;
 proxy_set_header X-Forwarded-Port $server_port;
 }
}

 

Github webhooks are functional with the proxied-url, builds are triggered, HTTP 200 return, all green and happy.

Testing from the instance itself with curl fails complaining about the missing event type:

 

jenkins:~$ curl -v -H "Content-Type: application/json" -X POST -d '' https://mywebhookurl.mydomain.com/github-webhook/



"Content-Type" content="text/html;charset=utf-8"/>
Error 400 Hook should contain event type

HTTP ERROR 400 Hook should contain event type

URI:/github-webhook/
STATUS:400
MESSAGE:Hook should contain event type
SERVLET:Stapler

"https://eclipse.org/jetty">Powered by Jetty:// 9.4.41.v20210516

jenkins-infra-bot avatar Jul 07 '21 16:07 jenkins-infra-bot

macchiang:
  • Original comment link
  • Raw content of original comment:

    Hi,

    Here is my workaround:

    1. Edit github-plugin-configuration.xml in Jenkins home. 2. Add <hookUrl>http://some.example.com/webhook</hookUrl>

    <?xml version='1.0' encoding='UTF-8'?>
    <github-plugin-configuration plugin="[email protected]">
      <configs>
    .....
      </configs>
      <hookUrl>http://some.example.com/github-webhook/</hookUrl>
    </github-plugin-configuration>
    
    

     3. Restart Jenkins.

Hi,

Here is my workaround:

1. Edit github-plugin-configuration.xml in Jenkins home.
2. Add http://some.example.com/webhook

'1.0' encoding='UTF-8'?>
"github@​1.12.0">
  
.....
  
  http://some.example.com/github-webhook/


 3. Restart Jenkins.

jenkins-infra-bot avatar Sep 07 '21 02:09 jenkins-infra-bot

tanisdlj:
  • Original comment link
  • Raw content of original comment:

    Hi Mac,

    Yes! That worked! Thanks a lot! Still, is a hacky-workaround for a bug that should be fairly easy to fix, hopefully they will give it some attention soon :/

Hi Mac,

Yes! That worked! Thanks a lot! Still, is a hacky-workaround for a bug that should be fairly easy to fix, hopefully they will give it some attention soon :/

jenkins-infra-bot avatar Sep 30 '21 10:09 jenkins-infra-bot

dkallman:
  • Original comment link
  • Raw content of original comment:

    I did this workaround but it is still reverting to the default hook URL

I did this workaround but it is still reverting to the default hook URL

jenkins-infra-bot avatar Nov 17 '21 19:11 jenkins-infra-bot

franknarf888:
  • Original comment link
  • Raw content of original comment:

    Facing the same problem

Facing the same problem

jenkins-infra-bot avatar Mar 26 '24 13:03 jenkins-infra-bot