Skip to content

Commit

Permalink
optimise nginx config
Browse files Browse the repository at this point in the history
  • Loading branch information
modem7 committed Dec 23, 2023
1 parent 0ef5419 commit 03a4d44
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions scripts/70-nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ events {
http {
proxy_temp_path /tmp/proxy_temp;
proxy_cache_path /tmp/mycache keys_zone=mycache:50m;
proxy_cache_path /tmp/mycache inactive=1h levels=1:2 use_temp_path=off keys_zone=mycache:10m max_size=200m;
client_body_temp_path /tmp/client_temp;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
Expand All @@ -28,7 +28,7 @@ http {
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/access.log main;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/mime.types;
default_type application/octet-stream;
Expand All @@ -38,6 +38,9 @@ http {
tcp_nopush on;
keepalive_timeout 65;
gzip on;
gzip_proxied any;
gzip_vary on;
gzip_http_version 1.1;
server {
# add proxy caches
Expand All @@ -55,7 +58,7 @@ http {
#try_files $uri $uri/ /index.html;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8088/janus;
proxy_pass http://localhost:8088/janus;
}
location /rtcapp {
Expand All @@ -81,18 +84,29 @@ http {
location ~* \.(jpg|jpeg|gif|png|css|js|ico|webp|tiff|ttf|svg|mp4)$ {
mp4;
mp4_buffer_size 1M;
mp4_max_buffer_size 3M;
mp4_max_buffer_size 20M;
add_header Accept-Ranges bytes;
# proxy_force_ranges on;
proxy_buffering on;
# add_header X-Proxy-Cache $upstream_cache_status;
add_header X-Cache-Status $upstream_cache_status;
aio threads=default;
# enable caching for mp4 videos
proxy_cache mycache;
proxy_cache_valid 200 300s;
proxy_cache_valid any 1h;
proxy_cache_lock on;
proxy_cache_background_update on;
proxy_cache_revalidate on;
# enable nginx slicing
slice 1m;
proxy_cache_key $host$uri$is_args$args$slice_range;
#proxy_cache_key $uri$is_args$args$slice_range;
proxy_set_header Range $slice_range;
proxy_http_version 1.1;
Expand All @@ -103,6 +117,8 @@ http {
proxy_cache_lock_age 200s;
proxy_cache_use_stale updating;
proxy_pass http://localhost:${PORT};
}
}
}
Expand Down

0 comments on commit 03a4d44

Please sign in to comment.