Using Jenkins with Nginx as a reverse proxy

Using Jenkins with Nginx:

server {
    listen 80;
    server_name jenkins.yamicode.com;
    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 http://jenkins.yamicode.com;

      # Required for new HTTP-based CLI
      proxy_http_version 1.1;
      proxy_request_buffering off;
      # workaround for https://issues.jenkins-ci.org/browse/JENKINS-45651
      add_header 'X-SSH-Endpoint' 'jenkins.yamicode.com:50022' always;
    }
}