环境
10.0.0.20 Nginx 10.0.0.21 jenkins
10.0.0.20 nginx
进入到nginx目录,去除无用字段输入到conf.d/jenkins.conf 文件中
[root@node1 ~]# cd /etc/nginx/ [root@node1 nginx]# egrep -v "#|^$" nginx.conf.default >conf.d/jenkins.conf
进入conf.d/jenkins.conf 文件进行配置
[root@node1 nginx]# cd conf.d/ [root@node1 conf.d]# vim jenkins.conf server { listen 80; server_name jenkins.wanglan.com; location / { proxy_pass http://10.0.0.21:8080; proxy_set_header HOST $HOST; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Request-Url $request_uri; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
配置完成后检查语法并平滑重启
[root@node1 conf.d]# nginx -t [root@node1 conf.d]# nginx -s reload
解析
[root@node1 ~]# vim /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.0.0.20 www.wanglan.com
10.0.0.21 jenkins
查询jenkins安装路径
[root@node2 ~]# rpm -ql jenkins | grep conf
查看端口(可以修改 这里默认)
56 JENKINS_PORT="8080"
Windows解析
# localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost 10.0.0.20 www.wanglan.com jenkins.wanglan.com
通过web 访问
http://jenkins.wanglan.com