亚洲视频二区_亚洲欧洲日本天天堂在线观看_日韩一区二区在线观看_中文字幕不卡一区

公告:魔扣目錄網(wǎng)為廣大站長提供免費收錄網(wǎng)站服務(wù),提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.430618.com 】, 免友鏈快審服務(wù)(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

背景:運維思路來講,前兩篇文章詳細(xì)介紹到j(luò)enkins部署,僅僅是對于體驗于學(xué)習(xí),但運維任重而道遠(yuǎn),往往生產(chǎn)不可輕易暴露自己的IP,因此前面我們學(xué)習(xí)到的IP+端口號的方式就不合適了,基于安全考慮,我們實現(xiàn)IP與端口封堵與反向代理,以至于更好的在生產(chǎn)環(huán)境落地;

 

一、前提:

1、Jenkins已安裝,詳細(xì)步驟移步《基于阿里云ECS centos8.0系統(tǒng)yum部署jenkins-2.277.3-1.1詳情》;

2、Nginx已安裝,本文手把手介紹;

 

二、基于YUM倉庫部署Nginx1.20

1、創(chuàng)建nginx.repo源,

cat <<EOF > /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF

2、完成nginx-mainline配置

yum-config-manager --enable nginx-mainline

3、安裝Nginx

yum install nginx -y

4、啟動并查看監(jiān)聽端口80,如圖常用命令(基于yum安裝systemctl好使)

systemctl start nginx.service  啟動nginx服務(wù) # 
systemctl stop nginx.service      停止服務(wù) # 
systemctl restart nginx.service     重新啟動服務(wù) # 
systemctl list-units --type=service   查看所有已啟動的服務(wù) # 
systemctl status nginx.service      查看服務(wù)當(dāng)前狀態(tài) # 
systemctl enable nginx.service      設(shè)置開機自啟動 # 
systemctl disable nginx.service     停止開機自啟動
nginx -v

需在nginx目錄下運行
nginx -s [signal]
nginx -s reload 刷新配置
nginx -s fast 快速stop
nginx -s graceful 優(yōu)雅stop
Jenkins基于Nginx實現(xiàn)域名訪問,反向代理詳細(xì)配置總結(jié)

 

三、Jenkins反向代理實現(xiàn)

1、nginx目錄下/etc/nginx/conf.d/,新建jenkins.conf

vim /etc/nginx/conf.d/jenkins.conf

2、粘貼如下內(nèi)容

upstream jenkins {
  keepalive 32; # keepalive connections
  server IP:8089; # jenkins ip and port
}

# Required for Jenkins websocket agents
map $http_upgrade $connection_upgrade {
  default upgrade;
  '' close;
}

server {
  listen          80;       # Listen on port 80 for IPv4 requests

  server_name     jenkins.10691.cn;  # replace 'jenkins.10691.cn' with your server domain name

  # this is the jenkins web root directory
  # (mentioned in the /etc/default/jenkins file)
  root            /usr/share/nginx/jenkins/;

  access_log      /var/log/nginx/jenkins/access.log;    ##需自行新建目錄
  error_log       /var/log/nginx/jenkins/error.log;    ##需自行新建目錄

  # pass through headers from Jenkins that Nginx considers invalid
  ignore_invalid_headers off;

  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 userContent folder
    # 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 / {
      sendfile off;
      proxy_pass         http://jenkins;
      proxy_redirect     default;
      proxy_http_version 1.1;

      # Required for Jenkins websocket agents
      proxy_set_header   Connection        $connection_upgrade;
      proxy_set_header   Upgrade           $http_upgrade;

      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   X-Forwarded-Proto $scheme;
      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_buffering            off;
      proxy_request_buffering    off; # Required for HTTP CLI commands
      proxy_set_header Connection ""; # Clear for keepalive
  }

}

3、如果在某些URL路徑方面遇到問題 Blue Ocean的 ,則可能需要在代理配置中添加以下代碼段

if ($request_uri ~* "/blue(/.*)") {
    proxy_pass http://YOUR_SERVER_IP:YOUR_JENKINS_PORT/blue$1;
    break;
}

4、重啟Nginx,瀏覽器http://jenkins.10691.cn,驗證即可;

分享到:
標(biāo)簽:代理
用戶無頭像

網(wǎng)友整理

注冊時間:

網(wǎng)站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨大挑戰(zhàn)2018-06-03

數(shù)獨一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運動步數(shù)有氧達人2018-06-03

記錄運動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評定2018-06-03

通用課目體育訓(xùn)練成績評定