Skip to content

Instantly share code, notes, and snippets.

@nginx-gists
nginx-gists / cookie_flags.conf
Last active May 6, 2021
Announcing NGINX Plus R24
View cookie_flags.conf
View cache_manager_min_free.conf
proxy_cache_path /var/cache/nginx keys_zone=cache_zone:10m min_free=100M;
server {
#...
location / {
proxy_pass http://backend;
proxy_cache cache_zone;
proxy_cache_key $uri;
}
}
@nginx-gists
nginx-gists / ubuntu_install.sh
Last active Jun 17, 2021
Automating Installation of WordPress with NGINX Unit on Ubuntu
View ubuntu_install.sh
#!/usr/bin/env bash
if [ "$EUID" -ne 0 ];then
>&2 echo "This script requires root level access to run"
exit 1
fi
if [ -z "${WORDPRESS_DB_PASSWORD}" ]; then
>&2 echo "WORDPRESS_DB_PASSWORD must be set"
>&2 echo "Here is a random one that you can paste:"
@nginx-gists
nginx-gists / app.go
Created Aug 11, 2020
Application Isolation with NGINX Unit
View app.go
package main
import (
"encoding/json"
"fmt"
"net/http"
"unit.nginx.org/go"
"os"
"strconv"
)
@nginx-gists
nginx-gists / ab_app.json
Last active Aug 10, 2020
Filesystem Isolation in NGINX Unit
View ab_app.json
{
"listeners": {
"*:80": {
"pass": "applications/ab_app"
}
},
"applications": {
"ab_app": {
"type": "php",
@nginx-gists
nginx-gists / 2_2_1_weights
Last active Jul 2, 2020
NGINX Unit 1.18.0 Adds Filesystem Isolation and Other Enhancements
View 2_2_1_weights
{
"servers": {
"192.168.0.100:8080": {
"weight": 2,
},
"192.168.0.101:8080": {
"weight": 2,
},
"192.168.0.102:8080"
}
@nginx-gists
nginx-gists / logging.conf
Created Jun 9, 2020
Announcing NGINX Plus R22
View logging.conf
js_import logging.js; # Load this JS file as the 'logging' module
js_set $raw_headers_in logging.rawHeadersOnError;
log_format json escape=none '{"response":'
'{"timestamp":"$time_iso8601","status":$status},'
'"request":'
'{"client":"$remote_addr","uri":"$request_uri","headers":$raw_headers_in}}';
server {
listen 80;
@nginx-gists
nginx-gists / .unit.conf.json
Last active May 7, 2020
Building Application Stacks With NGINX Unit
View .unit.conf.json
{
"listeners": {
"*:8080": {
"pass": "routes/wordpress"
}
},
"routes": {
"wordpress": [
{
"match": {
@nginx-gists
nginx-gists / fallback
Created Apr 8, 2020
NGINX Unit 1.16.0 Introduces New Yet Familiar Features
View fallback
{
"action": {
"share": "/data/www/",
"fallback": {
"pass": "applications/php_blog"
}
}
}
@nginx-gists
nginx-gists / dynamic_grpc.conf
Last active Apr 7, 2020
Announcing NGINX Plus R21
View dynamic_grpc.conf
keyval_zone zone=grpc-greeter:128K type=ip timeout=48h;
keyval $remote_addr $greeter_upstream zone=grpc-greeter;
server {
listen 50052 ssl http2;
ssl_certificate /etc/ssl/certificate.crt;
ssl_certificate_key /etc/ssl/privateKey.key;
location /helloworld.Greeter {
grpc_pass grpc://$greeter_upstream; #TLS termination