server { listen {{ http_standard_port }}; server_name {{ jenkins_hostname }}; access_log /var/log/nginx/jenkins_access.log; error_log /var/log/nginx/jenkins_error.log; location /userContent { # Have nginx handle all the static requests to the userContent folder files # NOTE: This is the $JENKINS_HOME dir root /var/lib/jenkins/; if (!-f $request_filename){ # This file does not exist, might be a directory or a /**view** url rewrite (.*) /$1 last; break; } sendfile on; } location @jenkins { sendfile off; proxy_pass http://127.0.0.1:{{ jenkins_port }}; proxy_redirect default; 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_max_temp_file_size 0; # This is the maximum upload size client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } location / { # This is the jenkins web root directory (mentioned in the /etc/default/jenkins file) root /var/run/jenkins/war/; # Optional configuration to detect and redirect iPhones if ($http_user_agent ~* '(iPhone|iPod)') { rewrite ^/$ /view/iphone/ redirect; } try_files $uri @jenkins; } }