Using Jenkins with Nginx as a reverse proxy

Using Jenkins with Nginx:

server {
    listen 80;
    location / {

      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;

      # Fix the "It appears that your reverse proxy set up is broken" error.
      proxy_pass          http://jenkins:8080;
      proxy_read_timeout  90;

      #proxy_redirect      http://jenkins:8080;

      # Required for new HTTP-based CLI
      proxy_http_version 1.1;
      proxy_request_buffering off;
      # workaround for
      add_header 'X-SSH-Endpoint' '' always;