{"id":18714,"date":"2016-03-04T13:22:32","date_gmt":"2016-03-04T19:22:32","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=18714"},"modified":"2022-06-03T03:43:45","modified_gmt":"2022-06-03T08:43:45","slug":"install-and-configure-jenkins-with-nginx-as-a-reverse-proxy-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/install-and-configure-jenkins-with-nginx-as-a-reverse-proxy-on-centos-7\/","title":{"rendered":"Install and configure Jenkins with Nginx as a reverse proxy on CentOS 7"},"content":{"rendered":"
In this article we will install and configure Jenkins with Nginx as a reverse proxy on a CentOS 7 VPS<\/a>.<\/p>\n Jenkins is a leading open source automation server built with Java that monitors executions of repeated jobs, such as building a software project or jobs run by cron. With Jenkins, organizations can accelerate the software development process through automation. It manages and controls development life-cycle processes of all kinds, including build, document, test, package, stage, deployment, static analysis and many more.<\/p>\n For Ubuntu use the tutorial below: <\/p>\n Builds can be started by various means, including being triggered by commit in a version control system, scheduling via a cron-like mechanism, building when other builds have completed, and by requesting a specific build URL.<\/p>\n REQUIREMENTS<\/strong><\/p>\n We will be using our SSD 1<\/strong> Linux VPS<\/a> hosting plan for this tutorial.<\/p>\n Log in to your server via SSH:<\/p>\n Before starting, enter the below command to check whether you have the proper version of CentOS installed on your machine:<\/p>\n It should give you the underneath output:<\/p>\n UPDATE THE SYSTEM<\/strong><\/p>\n Make sure your server is fully up to date:<\/p>\n INSTALL JAVA AND NGINX<\/strong><\/p>\n Your next step is to install Nginx along some needed dependencies and the nano text editor so you can edit some config files. Of course, you can use your favorite text editor.<\/p>\n Install the official Nginx repository for CentOS 7 and then install Nginx, nano etc… Use the below commands to do that:<\/p>\n Start Nginx and enable it to start on boot:<\/p>\n Now create a host directive for the domain from which you will access Jenkins. Open a file, let’s say called ‘your_domain.conf’ in the ‘\/etc\/nginx\/conf.d\/’ directory:<\/p>\n Paste the following:<\/p>\n Replace the ‘your_jenkins_site.com’ value with your own domain, save and close the file.<\/p>\n Test if the Nginx configuration is OK:<\/p>\n If everything is OK, restart Nginx for the changes to take effect:<\/p>\n Since Jenkins is built with Java, let’s install it with the yum package manager:<\/p>\n You can check the installed Java version:<\/p>\n INSTALL JENKINS<\/strong><\/p>\n Download the Jenkins repo and install Jenkins with the following commands:<\/p>\n Start the Jenkins server and enable it to start on boot with:<\/p>\n Congratulations, you have successfully installed Jenkins on your CentOS 7 VPS<\/a>. You can now open your favorite web browser and access Jenkins using the domain you configured in the Nginx conf file.<\/p>\n However, the installation is insecure and allows anyone on the network to launch processes on your behalf. Therefore enable authentication to discourage misuse. Go to Manage Jenkins<\/strong> (in the left menu).<\/p>\n Click ‘Setup Security’ on the page loaded. Enable security by checking the box next to ‘Enable security’.<\/p>\n Configure Jenkins to use it\u2019s own user database and disable sign ups:<\/p>\n Navigate to Matrix-based security under Authorization and check the box next to it. Then make sure that Anonymous has only the Read right under the View group to prevent Jenkins from crashing.<\/p>\n Click save at the bottom of the page. After that, you\u2019ll see a sign up form.<\/p>\n Enter a username, password, name and email. Use a lower case username to avoid confusion because Jenkins is assuming a lower case username will be used. After signing up, you will be the administrator of this fresh Jenkins install.<\/p>\n Once everything is up and running, it is up to you to create and schedule your first job, install plugins etc\u2026<\/p>\n Of course you don\u2019t have to do any of this if you use one of our Hosted Jenkins<\/a>\u00a0 services, in which case you can simply ask our expert Linux admins to install Jenkins<\/strong> for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n PS<\/strong>.<\/span> If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" In this article we will install and configure Jenkins with Nginx as a reverse proxy on a CentOS 7 VPS. … <\/p>\n
\nHow to Install Jenkins on Ubuntu 16.04<\/a><\/p>\n# ssh root@server_ip<\/pre>\n
# cat \/etc\/redhat-release<\/pre>\n
CentOS Linux release 7.2.1511 (Core)<\/pre>\n
# yum update<\/pre>\n
# rpm -Uvh http:\/\/nginx.org\/packages\/centos\/7\/noarch\/RPMS\/nginx-release-centos-7-0.el7.ngx.noarch.rpm\r\n\r\n# yum install nginx wget nano<\/pre>\n
# systemctl start nginx\r\n\r\n# systemctl enable nginx\r\n<\/pre>\n
# nano \/etc\/nginx\/conf.d\/your_domain.conf<\/pre>\n
upstream jenkins {\r\n server 127.0.0.1:8080;\r\n}\r\n\r\nserver {\r\n listen 80 default;\r\n server_name your_jenkins_site.com;\r\n\r\n access_log \/var\/log\/nginx\/jenkins.access.log;\r\n error_log \/var\/log\/nginx\/jenkins.error.log;\r\n\r\n proxy_buffers 16 64k;\r\n proxy_buffer_size 128k;\r\n\r\n location \/ {\r\n proxy_pass http:\/\/jenkins;\r\n proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;\r\n proxy_redirect off;\r\n\r\n proxy_set_header Host $host;\r\n proxy_set_header X-Real-IP $remote_addr;\r\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n proxy_set_header X-Forwarded-Proto https;\r\n }\r\n\r\n}<\/pre>\n
# nginx -t<\/pre>\n
# service nginx restart<\/pre>\n
# yum install java<\/pre>\n
# java -version\r\n\r\nopenjdk version \"1.8.0_71\"\r\nOpenJDK Runtime Environment (build 1.8.0_71-b15)\r\nOpenJDK 64-Bit Server VM (build 25.71-b15, mixed mode)<\/pre>\n
# wget -O \/etc\/yum.repos.d\/jenkins.repo http:\/\/pkg.jenkins-ci.org\/redhat-stable\/jenkins.repo\r\n\r\n# rpm --import https:\/\/jenkins-ci.org\/redhat\/jenkins-ci.org.key\r\n\r\n# yum install jenkins<\/pre>\n
# service jenkins start\r\n\r\n# systemctl enable jenkins<\/pre>\n