Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Ubuntu / Raspberry Pi – Install NGINX Load Balance DNS

Posted on February 20, 2018 By David Kittell
sudo apt install nginx

Replace the IP addresses with your IP addresses

sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf-original

sudo sed -i "/^\s*#/d;s/\s*#[^\"']*$//" /etc/nginx/nginx.conf && sudo sed -i '/^\s*$/d' /etc/nginx/nginx.conf

Modify your config file to look like this

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
	worker_connections 768;
}
http {
	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	include /etc/nginx/mime.types;
	default_type application/octet-stream;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_prefer_server_ciphers on;
	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;
	gzip on;
	gzip_disable "msie6";
	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
}
stream{
	server {
		listen 53  udp;
		listen 53; #tcp
		proxy_pass      dns_servers;
		error_log       /var/log/nginx/dns.log info;
		proxy_responses 1;
		proxy_timeout   1s;
	}

	upstream dns_servers {
		zone dns_mem 64k;
		server 10.40.20.6:53 fail_timeout=10s;
		server 10.40.20.5:53 fail_timeout=10s;
	}
}

When done you need to test the config

nginx -t

You should see something like

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Reference: https://www.nginx.com/blog/load-balancing-dns-traffic-nginx-plus/

All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code Debian DNS Raspberry Pi Raspbian (Raspberry Pi OS) Ubuntu UNIX UNIX Shell Scripts Zorin OS

Post navigation

Previous post
Next post

Related Posts

FormatDateTime Function

Posted on August 21, 2013October 26, 2015

This is a default function within VBScript that should work in any VBScript situation. FormatDateTime(date,format) Date is required and has to be in a valid format but easily can accept date() or now() Date() would only display the current date where now() would be date and time. Format would be…

Read More

SQLite – Auto-Increment / Auto Generate GUID

Posted on December 19, 2014May 13, 2016

Recently was asked if it’s possible to create an auto-incrementing GUID in SQLite. Here is one approach: In Firefox there is an add-on called SQLite Manager (also available at https://code.google.com/p/sqlite-manager/) Open Firefox, in the “Tools” menu select “SQLite Manager” With SQLite Manager open click on the “Database” menu and select…

Read More

Ektron Archive Content

Posted on February 4, 2014October 26, 2015

UPDATE [content] SET [searchable] = 0 ,end_date = ‘2014-02-04 12:10:00.000’ ,end_date_action = 2 WHERE content_id IN ( SELECT c.[content_id] FROM [content] c INNER JOIN [content_folder_tbl] cft ON c.folder_id = cft.folder_id WHERE — content_id = 34 cft.[folder_name] LIKE ‘OLD%’ ) Originally Posted on February 4, 2014Last Updated on October 26, 2015…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes