Friday, May 16, 2014

Adding URI prefix to Jenkins to enable ProxyPass redirection in Apache httpd

When you install jenkins using the package manager, JENKINS_HOME is set to /var/lib/jenkins and the default configuration under /etc/sysconfig/jenkins does not contain an URI prefix such as http://<url>/<uri>. Typically, you would to add an uri like "/jenkins" to allow proxying from Apache httpd running on the same server. To add the prefix and allow for Proxying in httpd, make the below changes

$ sudo vi /etc/sysconfig/jenkins
JENKINS_ARGS="--prefix=/jenkins"

$ sudo service jenkins restart

Once you restart, your jenkins landing page will appear only when you enter http://<ec2 instance>/jenkins

Next, you would need to edit your $APACHE_HOME/conf/httpd.conf file and make the below changes

$sudo vi httpd.conf (and add the below lines at the end of the file)
ProxyPass        /jenkins http://localhost:8080/jenkins
ProxyPassReverse /jenkins http://localhost:8080/jenkins

Note - Pl. be sure that below load modules are uncommented

*****************
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_express_module modules/mod_proxy_express.so
*****************

No comments:

Post a Comment