Skip to content

Instantly share code, notes, and snippets.

Avatar

Igor Tikhonov igortik

View GitHub Profile
@igortik
igortik / nginx_common.conf
Last active Jun 30, 2017
Nginx example with DDoS mitigation example (503 error trick)
View nginx_common.conf
server {
# ...
# files starting with .dot
#
location ~ /\. {
deny all;
@igortik
igortik / nginx_php_fpm_cache.conf
Last active Apr 6, 2016
Nginx location example for PHP-FPM with cache
View nginx_php_fpm_cache.conf
server {
# ...
location ~ \.php$ {
internal;
root /path;
# All requests to default > /index.php
@igortik
igortik / nginx_static.conf
Last active Apr 6, 2016
Nginx configuration example for static data
View nginx_static.conf
server {
listen 80;
server_name static.domain.tld;
# Logs
#
error_log /var/www/logs/nginx_errors.log error;
access_log off;
@igortik
igortik / nginx_php_fpm.conf
Last active Apr 6, 2016
Nginx PHP-FPM location example
View nginx_php_fpm.conf
server {
# ...
location ~ \.php$ {
internal;
root /path/;
# All requests to default > /index.php
try_files index.php =404;
@igortik
igortik / nginx_cloudflare.conf
Last active Aug 21, 2019
Nginx & Cloudflare real IP configuration
View nginx_cloudflare.conf
# Look for client IP in the X-Forwarded-For header
real_ip_header X-Forwarded-For;
# Ignore trusted IPs
real_ip_recursive on;
# Trusted list
set_real_ip_from 199.27.128.0/21;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
@igortik
igortik / nginx.conf
Last active May 14, 2022
Nginx optimized configuration with DDoS mitigation
View nginx.conf
user nginx;
# one(1) worker or equal the number of _real_ cpu cores. 4=4 core cpu
worker_processes 4;
# renice workers to reduce priority compared to system processes for
# machine health. worst case nginx will get ~25% system resources at nice=15
worker_priority -5;
@igortik
igortik / my.cnf
Created Apr 6, 2016
MySQL configuration with common optimisation and replication support
View my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used (fedora >= 15).
# If you need to run mysqld under a different user or group,
@igortik
igortik / nginx_local_dev_server.conf
Last active Apr 6, 2016
Nginx configuration for local web server and multiple apps
View nginx_local_dev_server.conf
server {
listen 80;
server_name ~^(?<app>.+)\.localhost$;
root /Users/user/www/$app/;
index index.html index.php;
location / {
try_files $uri $uri/ /index.php;