1.在Jenkins 官方網站(http://jenkins-ci.org/)下載最新版本war包。拷貝到 $TOMCAT_HOME/webapps 下(不用解壓)。啓動tomcat服務。nginx
2.找到nginx的配置文件,如nginx默認配置文件路徑在/usr/local/nginx/conf/nginx.conf。web
3.打開nginx.conf配置文件:sudo vim /usr/local/nginx/conf/nginx.confvim
4. 修改配置文件tomcat
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#keepalive_timeout 0;
keepalive_timeout 65;app
server {
listen 80;
server_name localhost;
#access_log /var/log/jenkins_access_log main;
#error_log /var/log/jenkins_error_log debug_http;
client_max_body_size 60M;
client_body_buffer_size 512k;
location / {
proxy_pass http://localhost:8080/;
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;
}
}
}webapp
將紅色字體部分加入到配置文件中。字體
5.重啓nginx服務網站
service nginx startspa
6.訪問jenkins頁面debug
http://locallhost/jenkins
這樣就能夠訪問到jenkins了,固然咱們如今和直接訪問jenkins(http://localhost:8080/jenkins)的區別是少了端口號,這是由於咱們在同一臺機器上,沒法直接體現出jenkins的反向代理功能。