{"id":304,"date":"2019-07-14T14:47:36","date_gmt":"2019-07-14T14:47:36","guid":{"rendered":"http:\/\/mohammedlakkadshaw.com\/blog\/?p=304"},"modified":"2019-07-14T14:47:36","modified_gmt":"2019-07-14T14:47:36","slug":"running-jenkins-behind-nginx-proxy","status":"publish","type":"post","link":"https:\/\/mohammedlakkadshaw.com\/blog\/running-jenkins-behind-nginx-proxy.html","title":{"rendered":"Running Jenkins behind NGINX Proxy"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I have a Jenkins server with a private IP address and an NGNIX server with a public IP. I wanted to point the domain for the Jenkins server to the NGINX server and the NGINX server would forward the request the Jenkins server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I got this working through NGINX proxy pass, here is NGNIX configuration that I have used to get it working.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Assume the domain used for Jenkins server is <strong>jenkins.mydomain.com<\/strong> and the IP address of the Jenkins server is <strong>192.168.1.20<\/strong> running at port <strong>8080<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On the Nginx server we create the file under the sites-available folder, here is the exact path: <code> \/etc\/nginx\/sites-available\/jenkins.mydomain.com<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>upstream jenkins {\n\tserver 192.168.1.20:8080 fail_timeout=0;\n}\n\nserver {\n\tlisten 80;\n\tserver_name jenkins.mydomain.com;\n\n\tlocation \/ {\n\t\tproxy_set_header\tHost $host:$server_port;\n\t\tproxy_set_header        X-Real-IP $remote_addr;\n\t\tproxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;\n\t\tproxy_set_header        X-Forwarded-Proto $scheme;\n\n\t\tproxy_pass\thttp:\/\/jenkins;\n\t\tproxy_read_timeout\t90;\n\n\t\tproxy_redirect\thttp:\/\/192.168.1.20:8080\/ http:\/\/jenkins.mydomain.com\/;\n\t\t# Required for new HTTP-based CLI\n\t\tproxy_http_version 1.1;\n\t\tproxy_request_buffering off;\n\t\t# workaround for https:\/\/issues.jenkins-ci.org\/browse\/JENKINS-45651\n\t\tadd_header 'X-SSH-Endpoint' 'jenkins.mydomain.com:50022' always;\n\t}\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then linked the jenkins.mydomain.com file to sites-enabled<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>sudo ln -s \/etc\/nginx\/sites-available\/jenkins.mydomain.com \/etc\/nginx\/sites-enabled\/<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Test the updated configuration<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>sudo nginx -t<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Restart the nginx server<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>sudo systemctl restart nginx<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s it! Let me know if you have any questions or comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a Jenkins server with a private IP address and an NGNIX server with a public IP. I wanted to point the domain for the Jenkins server to the NGINX server and the NGINX server would forward the request the Jenkins server. I got this working through NGINX proxy pass, here is NGNIX configuration [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-304","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/posts\/304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/comments?post=304"}],"version-history":[{"count":0,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/posts\/304\/revisions"}],"wp:attachment":[{"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/media?parent=304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/categories?post=304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohammedlakkadshaw.com\/blog\/wp-json\/wp\/v2\/tags?post=304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}