Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-66079

Override Hook URL check throws 411 error when using a reverse proxy

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • github-plugin
    • None
    • Debian 10
      Jenkins 2.289.2
      OpenJDK 11.0.11
      Github-plugin 1.33.1
      Google Chrome 91.0.4472.114 (also tested with Edge)

      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/
      
      <
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
      <title>Error 400 Hook should contain event type</title>
      </head>
      <body><h2>HTTP ERROR 400 Hook should contain event type</h2>
      <table>
      <tr><th>URI:</th><td>/github-webhook/</td></tr>
      <tr><th>STATUS:</th><td>400</td></tr>
      <tr><th>MESSAGE:</th><td>Hook should contain event type</td></tr>
      <tr><th>SERVLET:</th><td>Stapler</td></tr>
      </table>
      <hr><a href="https://eclipse.org/jetty">Powered by Jetty:// 9.4.41.v20210516</a><hr/>
      </body>
      </html>
      

       

       

      As far as I found, a 411 is thrown when no Content-Lenght is defined. Curl does that already whenever you post anything, but apparently the check in Jenkins is not sending it properly. Also can't save it, not sure if it's because of the check failing or due to #JENKINS-60738

      This prevents us to place Jenkins behind a safe proxy hence leaving us exposed pretty bad.

            lanwen Kirill Merkushev
            tanisdlj Diego
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: