Sunday, June 19, 2016

2 Steps to restrict Jenkins access by IP address or Host Name

Steps to fresh jenkins installtion on on Apache Tomcat Server :

If Jenkins is installed on Tomcat Server 

  1.  Add any of the below entry in the conf\context.xml file :
    • <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow=""/><!--Allow from Ip Address-->
    • <Valve className="org.apache.catalina.valves.RemoteAddrValve" deny=""/><!--Deny from Ip Address-->
    • <Valve className="org.apache.catalina.valves.RemoteHostValve" allow=""/><!--Allow from a Domain-->
    • <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|"/><!--Allow from multipl ip's-->
  2.  Restart the Tomcat Server
Now, when you try to access Jenkins url, you should get 403 error

If Jenkins is installed on Apache Server 

  1. Add all of the below entries in the conf\.htaccess file to allow access from ip '' and '' LAN only
    • Order Deny,Allow
    • Deny from all
    • Allow from
    • Allow from
  2. Restart the Apache Server

Now, when you try to access Jenkins url, you should get 403 error

Installing Jenkins on Apache Tomcat Server

First of all if you have not installed the Apache Tomcat Server, We will be going to install it on Windows following the below steps :
  • Download the Apache Server from Url :

  • Extract the Tomcat zip folder
  • Navigate to to 'conf' directory, path may be somewhat like '..\apache-tomcat-9.0.0.M8\conf' from where you have extracted the zip.
  • Open the Server.xml file and edit the PORT where you want the Tomcat to listen for the requests

  • Now start Command Prompt and go to '..\apache-tomcat-9.0.0.M8\bin' and call 'startup.bat'
  • Now start a browser and navigate to url '<your_system_ip:port_specified_in_step4>'. Example :
    • You should see Tomcat Successfully installed page. Congratulation!

Now, we will be moving to next part of configuring Jenkins behind the Tomcat Server  :
  •  Download Jenkins.war file from
  • Once downloaded, unzip and move the jenkins.war to directory '.\apache-tomcat-9.0.0.M8\webapps'
  • Restart the Tomcat. CTRL+C or call the .\apache-tomcat-9.0.0.M8\bin\shutdown.bat' and then start again.
    • Now when you navigate to, you should see jenkins successfully installed.

Feel free to leave comments !!!

AWS Certified Solutions Architect Associate - AWS Introduction - Questions

All the Best !!! Show Result !! Try Again !! ×