Issue
- How to configure nginx as load balancer in CJE
Environment
- CloudBees Jenkins Enterprise - Anywhere
Resolution
Nginx Load Balancer Example
For example, to use Nginx as your load balancer here’s what you would do:
- Use a dedicated VM instance running
Ubuntu 14.04 LTS (192.168.1.99)
. This instance must have network connectivity to allController nodes (192.168.1.240, 192.168.1.247, and 192.168.1.251)
. - Install nginx by executing on the instance,
sudo apt-get install nginx
- Add the following line to the file /etc/nginx/nginx.conf if it is not already there in the http block.
http {
...
include /etc/nginx/conf.d/*.conf;
}
- Create an additional file /etc/nginx/conf.d/jce.conf
upstream backend {
server 192.168.1.240;
server 192.168.1.247;
server 192.168.1.251;
}
log_format access_apps_path_mode '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
server {
listen 80;
server_name cje.example.com mesos.cje.example.com marathon.cje.example.com;
access_log /var/log/nginx/apps_path_mode.log access_apps_path_mode;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_redirect off;
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;
client_max_body_size 250m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffering off;
proxy_temp_file_write_size 64k;
}
}
- Restart Nginx by executing sudo service nginx restart
0 Comments