Skip to content

Instantly share code, notes, and snippets.

@1syo
Created December 29, 2015 06:56
Show Gist options
  • Save 1syo/eb2bafc2d2ba76b6270c to your computer and use it in GitHub Desktop.
Save 1syo/eb2bafc2d2ba76b6270c to your computer and use it in GitHub Desktop.
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/cache/jenkins/war;
index index.html;
server_name _;
server_tokens off;
location / {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
location ~ \.class$ { deny all; }
location ~ \.jar$ { deny all; }
location /WEB-INF { deny all; }
location /META-INF { deny all; }
try_files $uri @jenkins;
}
location /css {
expires 1y;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
}
location /images {
expires 1y;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
}
location /scripts {
expires 1y;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
}
location /help {
expires 1y;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
}
location @jenkins {
proxy_redirect off;
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 Authorization "";
proxy_connect_timeout 30;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_pass http://127.0.0.1:8080;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment