At the end of this lesson you will be able to connect to your Jenkins instance from a web browser. This web request passes through the nginx reverse web proxy we setup in a previous lesson.
On Master, edit the existing nginx configuration file for master:
sudo vi /etc/nginx/sites-available/master
Building on our existing nginx configuration, we include configuration options for Jenkins below the gogs configuration stanza, save and close:
location ^~ /jenkins/ { proxy_pass http://localhost:8080/jenkins/; # The following settings from https://wiki.jenkins-ci.org/display/JENKINS/Running+Hudson+behind+Nginx sendfile off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_max_temp_file_size 0; #this is the maximum upload size client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; }
The full nginx configuration file /etc/nginx/sites-available/master should look like this:
server { listen 80; server_name master; location /gogs/ { proxy_pass http://localhost:3000/; } location ^~ /jenkins/ { proxy_pass http://localhost:8080/jenkins/; # The following settings from https://wiki.jenkins-ci.org/display/JENKINS/Running+Hudson+behind+Nginx sendfile off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_max_temp_file_size 0; #this is the maximum upload size client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } }
The master site configuration is already enabled so all we need to do is restart the nginx service:
sudo service nginx restart
Now visit http://master/jenkins/ to access the Jenkins CI service through the reverse proxy.