forked from Verigreen/jenkins-tomcat-nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
executable file
·77 lines (62 loc) · 2.39 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 8081; # Listen on port 8081 for IPv4 requests
server_name localhost;
#Fix for the MIME label in the css files
include /etc/nginx/mime.types;
default_type application/octet-stream;
#this is the jenkins web root directory (mentioned in the /etc/default/jenkins file)
root /tomcat/webapps/ROOT;
access_log /var/log/nginx/jenkins/access.log;
error_log /var/log/nginx/jenkins/error.log;
location ~ "^\/static\/[0-9a-fA-F]{8}\/(images|css|scripts)\/(.*)$" {
#rewrite all static files into requests to the root
#E.g /static/12345678/images/something.png will become /images/something.png
rewrite "^\/static\/[0-9a-fA-F]{8}\/(images|css|scripts)\/(.*)$" /$1/$2 last;
}
location /userContent {
#have nginx handle all the static requests to the userContent folder files
#note : This is the $JENKINS_HOME directory, the userContent folder is
#located in the /var/jenkins_home/userContent directory
root /var/jenkins_home/;
if (!-f $request_filename){
#this file does not exist, might be a directory url such as htpp://jenkins.EG.com/userContent
rewrite (.*) /$1 last;
#stop outer-scoper inheritance and make it behave like a normal if statement
break;
}
sendfile on;
}
location @jenkins {
#let @jenkins designate this location
#if the css|js|image file is not found in root,
#this block will redirect to the jenkins server
sendfile off;
proxy_pass http://127.0.0.1:8080;
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 100m;
client_body_buffer_size 1280k;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
proxy_buffer_size 40k;
proxy_buffers 4 320k;
proxy_busy_buffers_size 640k;
proxy_temp_file_write_size 640k;
}
location / {
#try to dispatch the files in root
#if the requested file does not exist, redirect to the jenkins server
try_files $uri @jenkins;
}
}
}