Running Jenkins behind NGINX Proxy

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 that I have used to get it working.

Assume the domain used for Jenkins server is and the IP address of the Jenkins server is running at port 8080.

On the Nginx server we create the file under the sites-available folder, here is the exact path: /etc/nginx/sites-available/

upstream jenkins {
	server fail_timeout=0;

server {
	listen 80;

	location / {
		proxy_set_header	Host $host:$server_port;
		proxy_set_header        X-Real-IP $remote_addr;
		proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header        X-Forwarded-Proto $scheme;

		proxy_pass	http://jenkins;
		proxy_read_timeout	90;

		# Required for new HTTP-based CLI
		proxy_http_version 1.1;
		proxy_request_buffering off;
		# workaround for
		add_header 'X-SSH-Endpoint' '' always;

Then linked the file to sites-enabled

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Test the updated configuration

sudo nginx -t

Restart the nginx server

sudo systemctl restart nginx

That’s it! Let me know if you have any questions or comments.






Leave a Reply

Your email address will not be published. Required fields are marked *