-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnginx.conf
85 lines (70 loc) · 2.31 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
user www;
worker_processes 5; ## Default: 1
error_log logs/error.log;
worker_rlimit_nofile 8192;
events {
worker_connections 4096; ## Default: 1024
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
proxy_cache_path /tmp/nginx levels=1:2 keys_zone=my_cache:10m max_size=1g use_temp_path=off;
proxy_cache_lock on;
# https://www.nginx.com/blog/websocket-nginx/
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server { # simple reverse-proxy
listen 80;
# server_name domain2.com www.domain2.com;
access_log logs/cannedthighs.access.log main;
# https://www.nginx.com/blog/benefits-of-microcaching-nginx/
proxy_http_version 1.1; # Always upgrade to HTTP/1.1
proxy_set_header Connection ""; # Enable keepalives
proxy_set_header Accept-Encoding ""; # Optimize encoding
# https://www.nginx.com/blog/websocket-nginx/
location /ws {
proxy_pass http://node-upstream;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
location /images {
proxy_cache my_cache;
proxy_pass http://node-upstream;
proxy_cache_valid 20s;
}
# serve static files
location ~ \.(html|js|css)$ {
root /var/www/cannedthighs/public;
expires 1d;
}
location / {
proxy_pass http://node-upstream;
}
}
upstream node-upstream {
zone node 128k;
keepalive 20; # Keepalive pool to upstream
server 127.0.0.1:8000;
}
}
# https://docs.nginx.com/nginx/admin-guide/web-server/web-server/