title: Jenkins With Nginx Reverse Proxy And Resolver
body: <p>I am running Jenkins inside Docker behind an Nginx reverse proxy. Now I got a problem with the resolver. </p>
  
  <p>When I activate the resolver with:</p>
  
  <pre><code>set $backend "http://jenkins:8080/";
  proxy_pass $backend;
  </code></pre>
  
  <p>I will get the following error for all javascript files:</p>
  
  <pre><code>Refused to execute script from 'http://localhost/static/....js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
  </code></pre>
  
  <p>When I simply proxy pass without resolver:</p>
  
  <pre><code>proxy_pass http://jenkins:8080/;
  </code></pre>
  
  <p>It works but without resolver. The resolver is mandatory otherwise the setup won't work when the host <code>jenkins</code> changes it's Ip (Docker DNS Server).</p>
  
  <p>My configuration:</p>
  
  <pre><code>resolver 127.0.0.11  ipv6=off valid=30s;
  client_max_body_size  100m;
  keepalive_timeout     65;
  types_hash_max_size   2048;
  
  server {
      listen       80 default_server;
      listen       [::]:80 default_server;
      server_name  _;
      location / {
          set $backend "http://jenkins:8080/";
          proxy_pass $backend;
          proxy_set_header Host $host;
          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;
      }
  }
  </code></pre>