博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Running Jenkins behind Nginx
阅读量:5952 次
发布时间:2019-06-19

本文共 2532 字,大约阅读时间需要 8 分钟。

original : https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Nginx

In situations where you have existing web sites on your server, you may find it useful to run Jenkins (or the servlet container that Jenkins runs in) behind , so that you can bind Jenkins to the part of a bigger website that you may have. This document discusses some of the approaches for doing this.

When a request arrives for certain URLs, Nginx becomes a proxy and further forward that request to Jenkins, then it forwards the response back to the client. A typical set up for mod_proxy would look like this:

server {  listen          80;       # Listen on port 80 for IPv4 requests  server_name     jenkins.example.com;  #this is the jenkins web root directory (mentioned in the /etc/default/jenkins file)  root            /var/run/jenkins/war/;  access_log      /var/log/nginx/jenkins/access.log;  error_log       /var/log/nginx/jenkins/error.log;  location ~ "^/static/[0-9a-fA-F]{8}\/(.*)$" {    #rewrite all static files into requests to the root    #E.g /static/12345678/css/something.css will become /css/something.css    rewrite "^/static/[0-9a-fA-F]{8}\/(.*)" /$1 last;  }  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: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       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 / {     # Optional configuration to detect and redirect iPhones      if ($http_user_agent ~* '(iPhone|iPod)') {          rewrite ^/$ /view/iphone/ redirect;      }      try_files $uri @jenkins;   }}

This assumes that you run Jenkins on port 8080. Remember to create the folder /var/log/nginx/jenkins.

转载地址:http://ffoxx.baihongyu.com/

你可能感兴趣的文章
Web Storage 与cookies
查看>>
Android Gallery2技术分析
查看>>
微信群 保存到通讯录
查看>>
路由器和iP地址的那些事
查看>>
Glide 这样用,更省内存!!!
查看>>
php无法连接mysql(selinux)
查看>>
[面试专题]Vue.js 2.0 独立构建和运行时构建的区别
查看>>
React 初探
查看>>
如何让产品用户拥有一流的上传体验
查看>>
前端性能优化——http首部
查看>>
FreeRTOS(一)——任务管理
查看>>
移动端网页怎么做?
查看>>
第5章 高效的多线程日志
查看>>
协议 - 收藏集 - 掘金
查看>>
Kotlin教程 - 收藏集 - 掘金
查看>>
deferred对象
查看>>
2017年3月份前端资源分享
查看>>
Node学习记录: 图片爬虫
查看>>
cookie与session的区别与联系
查看>>
黄东旭:When TiDB Meets Kubernetes
查看>>