Skip to content

Commit d93a769

Browse files
author
Serghey Rodin
committed
nginx config update
1 parent 08247f2 commit d93a769

File tree

14 files changed

+323
-105
lines changed

14 files changed

+323
-105
lines changed

install/debian/7/nginx/nginx.conf

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Server globals
22
user www-data;
3-
worker_processes 2;
4-
error_log /var/log/nginx/error.log;
3+
worker_processes auto;
4+
worker_rlimit_nofile 65535;
5+
error_log /var/log/nginx/error.log crit;
56
pid /var/run/nginx.pid;
67

78

89
# Worker config
910
events {
1011
worker_connections 1024;
1112
use epoll;
13+
multi_accept on;
1214
}
1315

1416

@@ -37,7 +39,7 @@ http {
3739
'"$status" $body_bytes_sent "$http_referer" '
3840
'"$http_user_agent" "$http_x_forwarded_for"';
3941
log_format bytes '$body_bytes_sent';
40-
#access_log /var/log/nginx/access.log main;
42+
#access_log /var/log/nginx/access.log main;
4143
access_log off;
4244

4345

@@ -51,9 +53,9 @@ http {
5153
gzip_comp_level 9;
5254
gzip_min_length 512;
5355
gzip_buffers 8 64k;
54-
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml application/x-font-ttf font/opentype;
56+
gzip_types text/plain text/css text/javascript text/js text/xml application/json application/javascript application/x-javascript application/xml application/xml+rss application/x-font-ttf image/svg+xml font/opentype;
5557
gzip_proxied any;
56-
58+
gzip_disable "MSIE [1-6]\.";
5759

5860
# Proxy settings
5961
proxy_redirect off;
@@ -103,21 +105,30 @@ http {
103105
error_page 502 503 504 /error/50x.html;
104106

105107

106-
# Cache
107-
proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=512m;
108+
# Cache settings
109+
proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=1024m;
108110
proxy_cache_key "$host$request_uri $cookie_user";
109111
proxy_temp_path /var/cache/nginx/temp;
110112
proxy_ignore_headers Expires Cache-Control;
111113
proxy_cache_use_stale error timeout invalid_header http_502;
112-
proxy_cache_valid any 3d;
114+
proxy_cache_valid any 1d;
115+
113116

117+
# Cache bypass
114118
map $http_cookie $no_cache {
115119
default 0;
116120
~SESS 1;
117121
~wordpress_logged_in 1;
118122
}
119123

120124

125+
# File cache settings
126+
open_file_cache max=10000 inactive=30s;
127+
open_file_cache_valid 60s;
128+
open_file_cache_min_uses 2;
129+
open_file_cache_errors off;
130+
131+
121132
# Wildcard include
122133
include /etc/nginx/conf.d/*.conf;
123134
}

install/debian/8/nginx/nginx.conf

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Server globals
22
user www-data;
3-
worker_processes 2;
4-
error_log /var/log/nginx/error.log;
3+
worker_processes auto;
4+
worker_rlimit_nofile 65535;
5+
error_log /var/log/nginx/error.log crit;
56
pid /var/run/nginx.pid;
67

78

89
# Worker config
910
events {
1011
worker_connections 1024;
1112
use epoll;
13+
multi_accept on;
1214
}
1315

1416

@@ -37,7 +39,7 @@ http {
3739
'"$status" $body_bytes_sent "$http_referer" '
3840
'"$http_user_agent" "$http_x_forwarded_for"';
3941
log_format bytes '$body_bytes_sent';
40-
#access_log /var/log/nginx/access.log main;
42+
#access_log /var/log/nginx/access.log main;
4143
access_log off;
4244

4345

@@ -51,9 +53,9 @@ http {
5153
gzip_comp_level 9;
5254
gzip_min_length 512;
5355
gzip_buffers 8 64k;
54-
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml application/x-font-ttf font/opentype;
56+
gzip_types text/plain text/css text/javascript text/js text/xml application/json application/javascript application/x-javascript application/xml application/xml+rss application/x-font-ttf image/svg+xml font/opentype;
5557
gzip_proxied any;
56-
58+
gzip_disable "MSIE [1-6]\.";
5759

5860
# Proxy settings
5961
proxy_redirect off;
@@ -103,21 +105,30 @@ http {
103105
error_page 502 503 504 /error/50x.html;
104106

105107

106-
# Cache
107-
proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=512m;
108+
# Cache settings
109+
proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=1024m;
108110
proxy_cache_key "$host$request_uri $cookie_user";
109111
proxy_temp_path /var/cache/nginx/temp;
110112
proxy_ignore_headers Expires Cache-Control;
111113
proxy_cache_use_stale error timeout invalid_header http_502;
112-
proxy_cache_valid any 3d;
114+
proxy_cache_valid any 1d;
115+
113116

117+
# Cache bypass
114118
map $http_cookie $no_cache {
115119
default 0;
116120
~SESS 1;
117121
~wordpress_logged_in 1;
118122
}
119123

120124

125+
# File cache settings
126+
open_file_cache max=10000 inactive=30s;
127+
open_file_cache_valid 60s;
128+
open_file_cache_min_uses 2;
129+
open_file_cache_errors off;
130+
131+
121132
# Wildcard include
122133
include /etc/nginx/conf.d/*.conf;
123134
}

install/rhel/5/nginx/nginx.conf

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Server globals
22
user nginx;
3-
worker_processes 2;
4-
error_log /var/log/nginx/error.log;
3+
worker_processes auto;
4+
worker_rlimit_nofile 65535;
5+
error_log /var/log/nginx/error.log crit;
56
pid /var/run/nginx.pid;
67

78

89
# Worker config
910
events {
1011
worker_connections 1024;
1112
use epoll;
13+
multi_accept on;
1214
}
1315

1416

@@ -37,7 +39,7 @@ http {
3739
'"$status" $body_bytes_sent "$http_referer" '
3840
'"$http_user_agent" "$http_x_forwarded_for"';
3941
log_format bytes '$body_bytes_sent';
40-
#access_log /var/log/nginx/access.log main;
42+
#access_log /var/log/nginx/access.log main;
4143
access_log off;
4244

4345

@@ -51,8 +53,9 @@ http {
5153
gzip_comp_level 9;
5254
gzip_min_length 512;
5355
gzip_buffers 8 64k;
54-
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml application/x-font-ttf font/opentype;
56+
gzip_types text/plain text/css text/javascript text/js text/xml application/json application/javascript application/x-javascript application/xml application/xml+rss application/x-font-ttf image/svg+xml font/opentype;
5557
gzip_proxied any;
58+
gzip_disable "MSIE [1-6]\.";
5659

5760

5861
# Proxy settings
@@ -67,6 +70,29 @@ http {
6770
proxy_buffers 32 4k;
6871

6972

73+
# Cloudflare https://www.cloudflare.com/ips
74+
set_real_ip_from 199.27.128.0/21;
75+
set_real_ip_from 173.245.48.0/20;
76+
set_real_ip_from 103.21.244.0/22;
77+
set_real_ip_from 103.22.200.0/22;
78+
set_real_ip_from 103.31.4.0/22;
79+
set_real_ip_from 141.101.64.0/18;
80+
set_real_ip_from 108.162.192.0/18;
81+
set_real_ip_from 190.93.240.0/20;
82+
set_real_ip_from 188.114.96.0/20;
83+
set_real_ip_from 197.234.240.0/22;
84+
set_real_ip_from 198.41.128.0/17;
85+
set_real_ip_from 162.158.0.0/15;
86+
set_real_ip_from 104.16.0.0/12;
87+
set_real_ip_from 172.64.0.0/13;
88+
#set_real_ip_from 2400:cb00::/32;
89+
#set_real_ip_from 2606:4700::/32;
90+
#set_real_ip_from 2803:f800::/32;
91+
#set_real_ip_from 2405:b500::/32;
92+
#set_real_ip_from 2405:8100::/32;
93+
real_ip_header CF-Connecting-IP;
94+
95+
7096
# SSL PCI Compliance
7197
ssl_session_cache shared:SSL:10m;
7298
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
@@ -80,21 +106,30 @@ http {
80106
error_page 502 503 504 /error/50x.html;
81107

82108

83-
# Cache
84-
proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=512m;
85-
proxy_temp_path /var/cache/nginx/temp;
109+
# Cache settings
110+
proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=1024m;
86111
proxy_cache_key "$host$request_uri $cookie_user";
112+
proxy_temp_path /var/cache/nginx/temp;
87113
proxy_ignore_headers Expires Cache-Control;
88114
proxy_cache_use_stale error timeout invalid_header http_502;
89-
proxy_cache_valid any 3d;
115+
proxy_cache_valid any 1d;
90116

117+
118+
# Cache bypass
91119
map $http_cookie $no_cache {
92120
default 0;
93121
~SESS 1;
94122
~wordpress_logged_in 1;
95123
}
96124

97125

126+
# File cache settings
127+
open_file_cache max=10000 inactive=30s;
128+
open_file_cache_valid 60s;
129+
open_file_cache_min_uses 2;
130+
open_file_cache_errors off;
131+
132+
98133
# Wildcard include
99134
include /etc/nginx/conf.d/*.conf;
100135
}

install/rhel/6/nginx/nginx.conf

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Server globals
22
user nginx;
3-
worker_processes 2;
4-
error_log /var/log/nginx/error.log;
3+
worker_processes auto;
4+
worker_rlimit_nofile 65535;
5+
error_log /var/log/nginx/error.log crit;
56
pid /var/run/nginx.pid;
67

78

89
# Worker config
910
events {
1011
worker_connections 1024;
1112
use epoll;
13+
multi_accept on;
1214
}
1315

1416

@@ -37,7 +39,7 @@ http {
3739
'"$status" $body_bytes_sent "$http_referer" '
3840
'"$http_user_agent" "$http_x_forwarded_for"';
3941
log_format bytes '$body_bytes_sent';
40-
#access_log /var/log/nginx/access.log main;
42+
#access_log /var/log/nginx/access.log main;
4143
access_log off;
4244

4345

@@ -51,8 +53,9 @@ http {
5153
gzip_comp_level 9;
5254
gzip_min_length 512;
5355
gzip_buffers 8 64k;
54-
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml application/x-font-ttf font/opentype;
56+
gzip_types text/plain text/css text/javascript text/js text/xml application/json application/javascript application/x-javascript application/xml application/xml+rss application/x-font-ttf image/svg+xml font/opentype;
5557
gzip_proxied any;
58+
gzip_disable "MSIE [1-6]\.";
5659

5760

5861
# Proxy settings
@@ -67,6 +70,29 @@ http {
6770
proxy_buffers 32 4k;
6871

6972

73+
# Cloudflare https://www.cloudflare.com/ips
74+
set_real_ip_from 199.27.128.0/21;
75+
set_real_ip_from 173.245.48.0/20;
76+
set_real_ip_from 103.21.244.0/22;
77+
set_real_ip_from 103.22.200.0/22;
78+
set_real_ip_from 103.31.4.0/22;
79+
set_real_ip_from 141.101.64.0/18;
80+
set_real_ip_from 108.162.192.0/18;
81+
set_real_ip_from 190.93.240.0/20;
82+
set_real_ip_from 188.114.96.0/20;
83+
set_real_ip_from 197.234.240.0/22;
84+
set_real_ip_from 198.41.128.0/17;
85+
set_real_ip_from 162.158.0.0/15;
86+
set_real_ip_from 104.16.0.0/12;
87+
set_real_ip_from 172.64.0.0/13;
88+
#set_real_ip_from 2400:cb00::/32;
89+
#set_real_ip_from 2606:4700::/32;
90+
#set_real_ip_from 2803:f800::/32;
91+
#set_real_ip_from 2405:b500::/32;
92+
#set_real_ip_from 2405:8100::/32;
93+
real_ip_header CF-Connecting-IP;
94+
95+
7096
# SSL PCI Compliance
7197
ssl_session_cache shared:SSL:10m;
7298
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
@@ -80,21 +106,30 @@ http {
80106
error_page 502 503 504 /error/50x.html;
81107

82108

83-
# Cache
84-
proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=512m;
85-
proxy_temp_path /var/cache/nginx/temp;
109+
# Cache settings
110+
proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=1024m;
86111
proxy_cache_key "$host$request_uri $cookie_user";
112+
proxy_temp_path /var/cache/nginx/temp;
87113
proxy_ignore_headers Expires Cache-Control;
88114
proxy_cache_use_stale error timeout invalid_header http_502;
89-
proxy_cache_valid any 3d;
115+
proxy_cache_valid any 1d;
90116

117+
118+
# Cache bypass
91119
map $http_cookie $no_cache {
92120
default 0;
93121
~SESS 1;
94122
~wordpress_logged_in 1;
95123
}
96124

97125

126+
# File cache settings
127+
open_file_cache max=10000 inactive=30s;
128+
open_file_cache_valid 60s;
129+
open_file_cache_min_uses 2;
130+
open_file_cache_errors off;
131+
132+
98133
# Wildcard include
99134
include /etc/nginx/conf.d/*.conf;
100135
}

0 commit comments

Comments
 (0)