Skip to content

Instantly share code, notes, and snippets.

@kmjones1979
kmjones1979 / keepalived.conf
Created June 15, 2017 19:37
Mast keepalived.conf
vrrp_script chk_nginx_service {
script "/usr/lib/keepalived/nginx-ha-check"
interval 3
weight 50
}
vrrp_instance VI_1 {
interface eth0
state MASTER
@kmjones1979
kmjones1979 / redirect.conf
Created June 5, 2017 20:29
[NGINX Plus] Redirect all HTTP traffic to HTTPS
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
status_zone example.com_80;
location / {
@kmjones1979
kmjones1979 / links.md
Last active March 27, 2017 04:23
ODW 2016 Webinar Links
@kmjones1979
kmjones1979 / lb.conf
Created November 17, 2016 04:55
Example NGINX Plus load balancer configuration - ODW 2016
server {
listen 80;
server_name example.com *.example.com;
status_zone example_com_80;
location / {
proxy_pass http://backend;
}
@kmjones1979
kmjones1979 / backend.conf
Created November 17, 2016 04:53
Example NGINX Plus backend configuration
server {
listen 8001;
listen 8002;
server_name example.com *.example.com;
status_zone backend_800X;
location / {
return 200 "This is a server listening on $server_addr:$server_port \n";
@kmjones1979
kmjones1979 / status.conf
Created November 17, 2016 04:48
Example NGINX status configuration
server {
listen 8080;
server_name localhost example.com *.example.com;
location / {
return 301 /status.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
@kmjones1979
kmjones1979 / nginx_syntax_vim.sh
Last active November 17, 2016 00:09
Enable syntax highlighting within vim for NGINX configuration files
#!/bin/bash
wget -O nginx.vim http://www.vim.org/scripts/download_script.php\?src_id\=19394
mkdir -p ~/.vim/syntax
mv nginx.vim ~/.vim/syntax/
echo "au BufRead,BufNewFile /etc/nginx/*,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif" | tee -a ~/.vim/filetype.vim
@kmjones1979
kmjones1979 / nginx.conf
Created August 3, 2016 16:50
Dynamic Cache based on header
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@kmjones1979
kmjones1979 / nginx.conf
Last active November 15, 2021 11:05
This is an example NGINX configuration for the blog: Performing A/B Testing with NGINX - This demonstrates split_clients based routing on an argument named token
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
default_type text/html;
log_format main '$remote_addr -> $request $status $body_bytes_sent bytes -> $upstream_addr';
access_log /var/log/nginx/access.log main;
@kmjones1979
kmjones1979 / nginx.conf
Last active November 28, 2017 22:48
This is an example NGINX configuration for the blog: Performing A/B Testing with NGINX - This example demonstrates the sticky route functionality
events { worker_connections 2014; }
http {
default_type text/plain;
log_format cookie '$cookie_route - $route_cookie, '
'$request_uri - $route_uri, '
'$route - $upstream_addr';
error_log /var/log/nginx/debug_error.log debug;