如何配置 Jenkins 在端口 80 上运行 [英] How to configure Jenkins to run on port 80
问题描述
我正在运行 Ubuntu 11.10 并运行 sudo apt-get install jenkins
在这个系统上安装 Jenkins.
I'm running Ubuntu 11.10 and have run sudo apt-get install jenkins
to install Jenkins on this system.
我看过一些关于如何设置反向代理(Apache、Nginx 等)的教程,但是这是一个专用于 jenkins 的 VM,我希望在让 jenkins 在端口上运行时尽可能保持精简80.
I've seen some tutorials on how to setup a reverse proxy (Apache, Nginx, etc), however this is a VM dedicated for just jenkins and I'd like keep it as lean as possible while having jenkins running on port 80.
我在 /etc/init/jenkins.conf
中找到了 upstart 配置并将端口修改为 80 env HTTP_PORT=80
I've found the upstart config in /etc/init/jenkins.conf
and modified the port to 80 env HTTP_PORT=80
当我通过 service jenkins start
启动 jenkins 时,ps
显示它运行了几秒钟然后终止.
When I start jenkins via service jenkins start
, ps
reveals that it runs for a few seconds then terminates.
这是因为 jenkins 在特权端口上以 jenkins
用户身份运行吗?如果是这样,我该如何解决这个问题?欢迎任何其他想法.
Is this because jenkins is running as the jenkins
user on a privileged port? If so, how do I fix this? Any other ideas a welcome.
这是新贵的配置:
description "jenkins: Jenkins Continuous Integration Server"
author "James Page <james.page@ubuntu.com>"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]
env USER="jenkins"
env GROUP="jenkins"
env JENKINS_LOG="/var/log/jenkins"
env JENKINS_ROOT="/usr/share/jenkins"
env JENKINS_HOME="/var/lib/jenkins"
env JENKINS_RUN="/var/run/jenkins"
env HTTP_PORT=80
env AJP_PORT=-1
env JAVA_OPTS=""
env JAVA_HOME="/usr/lib/jvm/default-java"
limit nofile 8192 8192
pre-start script
test -f $JENKINS_ROOT/jenkins.war || { stop ; exit 0; }
$JENKINS_ROOT/bin/maintain-plugins.sh
mkdir $JENKINS_RUN > /dev/null 2>&1 || true
chown -R $USER:$GROUP $JENKINS_RUN || true
end script
script
JENKINS_ARGS="--webroot=$JENKINS_RUN/war --httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT"
exec daemon --name=jenkins --inherit --output=$JENKINS_LOG/jenkins.log --user=$USER
-- $JAVA_HOME/bin/java $JAVA_OPTS -jar $JENKINS_ROOT/jenkins.war $JENKINS_ARGS
--preferredClassLoader=java.net.URLClassLoader
end script
推荐答案
尝试 '身份验证':
sudo apt-get install authbind
sudo touch /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80
sudo chown jenkins /etc/authbind/byport/80
然后将上面的脚本修改为(在$JAVA_HOME/bin/java
部分之前添加authbind
):
Then modify the script above to have (add authbind
before the $JAVA_HOME/bin/java
part):
exec daemon --name=jenkins --inherit --output=$JENKINS_LOG/jenkins.log
--user=$USER -- authbind $JAVA_HOME/bin/java $JAVA_OPTS
-jar $JENKINS_ROOT/jenkins.war $JENKINS_ARGS
--preferredClassLoader=java.net.URLClassLoader
对于较新的 Ubuntu 安装 (14.04) 上较新的 Jenkins 安装 (1.598),编辑 /etc/init.d/jenkins
并在 $JAVA<之前添加
authbind
/代码>
For newer Jenkins installations (1.598) on newer Ubuntu installations (14.04) edit /etc/init.d/jenkins
and add authbind
before $JAVA
$SU -l $JENKINS_USER --shell=/bin/bash -c "$DAEMON $DAEMON_ARGS -- authbind $JAVA $JAVA_ARGS -jar $JENKINS_WAR $JENKINS_ARGS" || return 2
如所述Alan(见下面的评论)如果你需要 IPv6 并且你的系统低于 Quantal 你可以代替使用 apt-get
安装 authbind
下载更高版本.确保你已经安装了 libc6
和 libc6-udeb
.这是来自 Ubuntu 的 authbind
2.1.1 版:
As mentioned by Alan (see comment below) if you need IPv6 and your system is lower than Quantal you can instead of using apt-get
to install authbind
download a higher version.
Make sure you have libc6
and libc6-udeb
installed. Here is authbind
version 2.1.1 from Ubuntu:
然后执行:
sudo dpkg -i authbind_2.1.1_amd64.deb
# or sudo dpkg -i authbind_2.1.1_i386.deb
sudo touch /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80
sudo chown jenkins /etc/authbind/byport/80
这篇关于如何配置 Jenkins 在端口 80 上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!