Skip to content

Instantly share code, notes, and snippets.

View igortik's full-sized avatar

Igor Tikhonov igortik

View GitHub Profile
@igortik
igortik / nginx_common.conf
Last active June 30, 2017 18:42
Nginx example with DDoS mitigation example (503 error trick)
server {
# ...
# files starting with .dot
#
location ~ /\. {
deny all;
@igortik
igortik / nginx_php_fpm_cache.conf
Last active April 6, 2016 18:38
Nginx location example for PHP-FPM with cache
server {
# ...
location ~ \.php$ {
internal;
root /path;
# All requests to default > /index.php
@igortik
igortik / nginx_static.conf
Last active April 6, 2016 18:34
Nginx configuration example for static data
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 April 6, 2016 18:35
Nginx PHP-FPM location example
server {
# ...
location ~ \.php$ {
internal;
root /path/;
# All requests to default > /index.php
try_files index.php =404;
@igortik
igortik / nginx_cloudflare.conf
Last active August 21, 2019 22:57
Nginx & Cloudflare real IP configuration
# 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 July 15, 2023 04:09
Nginx optimized configuration with DDoS mitigation
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 April 6, 2016 18:21
MySQL configuration with common optimisation and replication support
[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 April 6, 2016 18:40
Nginx configuration for local web server and multiple apps
server {
listen 80;
server_name ~^(?<app>.+)\.localhost$;
root /Users/user/www/$app/;
index index.html index.php;
location / {
try_files $uri $uri/ /index.php;