Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Ubuntu 修改 Jenkins 預設埠口 8080 為 8082 解決埠口衝突

編輯:關於 Linux

Jenkins 預設佔用埠口 8080,與其他服務(如 Tomcat、Nginx proxy)衝突。Ubuntu 下修改 Jenkins 埠口需調整兩處:/etc/init.d/jenkins 啟動腳本的 check_tcp_port 參數,與 /etc/default/jenkins 設定檔的 HTTP_PORT。

修改步驟

1. 編輯啟動腳本 /etc/init.d/jenkins

vi /etc/init.d/jenkins
# 找到 do_start() 函數中的 check_tcp_port 行:
check_tcp_port "http" "$HTTP_PORT" "8082" || return 1
# 將 8080 改為 8082(或所需埠口)

2. 編輯預設設定 /etc/default/jenkins

vi /etc/default/jenkins
# 修改:
HTTP_PORT=8082
# 原為 HTTP_PORT=8080

3. 重啟 Jenkins 驗證

service jenkins restart
# 或
/etc/init.d/jenkins restart

ps -ef | grep java
# jenkins  7234  7233  99 11:14 ?  00:00:04 /usr/bin/java -jar /usr/share/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8082 --ajp13Port=-1
# 確認 --httpPort=8082 生效

Jenkins 埠口修改驗證截圖

補充:反向代理與 HTTPS

  • 生產環境建議 Nginx 反向代理至 8082,並終止 HTTPS:
server {
    listen 443 ssl;
    server_name ci.example.com;
    location / {
        proxy_pass https://localhost:8082;
        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;
    }
}
  • Jenkins 設定 Manage Jenkins → Configure Global Security → Prevent Cross Site Request Forgery exploits 勾選並設定 X-Forwarded-Proto 標頭信任。
Copyright © Windows教程網 All Rights Reserved