user www-data;
worker_processes auto;
worker_cpu_affinity auto;
worker_rlimit_nofile 300000;

events {
worker_connections 65000;
use epoll;
accept_mutex on;
multi_accept on;
}

thread_pool pool_stb threads=32 max_queue=0;

#HTTP
http {
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
aio threads=pool_stb;
client_body_timeout 150s;
client_header_timeout 150s;
client_max_body_size 64m;
default_type application/octet-stream;
fastcgi_read_timeout 200;
include mime.types;
keepalive_timeout 60;
lingering_close off;
reset_timedout_connection on;
send_timeout 60;
sendfile on;
sendfile_max_chunk 512k;
tcp_nodelay on;
tcp_nopush on;
server_tokens off;
gzip off;

server {
index index.php index.html index.htm;
root /var/www/html/;
server_tokens off;
listen 80;
chunked_transfer_encoding off;
server_name _;

#Smart TV
location ~ ^/smarttv/([a-z\/]+)/js/(.*).js$ {
return 301 /smarttv/stb.php;
}

#Loader
location /loader.js {
return 301 /loader.php;
}

#IVI
location ~ ^/vision.+/bundle\.js$ {
return 301 /loader.php;
}

#SS-IPTV
location /tv.js {
if ($http_host ~ "app.ss-iptv.com") {
return 301 /loader.php;
}
}

#Portal
location ~ ^/static/portal/standalone\.js$ {
return 301 /loader.php;
}

#Duplex IPTV
location ~ ^/apps/DuplexIPTV/(.*).js$ {
return 301 /smarttv/stb.php;
}

#TV3
location ~ ^/iptv/smarttv/(.*).js$ {
return 301 /smarttv/stb.php;
}

#IPTV
location ~ ^/iptv/smarttv/(.*).html$ {
return 301 /index.html;
}

#Live
location ~ ^/(.*)/live/(.*)$ {
return 301 /redirect.php?type=live&dns=$1&data=$2;
}

#Movie
location ~ ^/(.*)/movie/(.*)$ {
return 301 /redirect.php?type=movie&dns=$1&data=$2;
}

#Series
location ~ ^/(.*)/series/(.*)$ {
return 301 /redirect.php?type=series&dns=$1&data=$2;
}

#PHP-FPM
location ~ \.php$ {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
include fastcgi_params;
fastcgi_buffering on;
fastcgi_buffers 96 32k;
fastcgi_buffer_size 32k;
fastcgi_max_temp_file_size 0;
fastcgi_keep_conn on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
}
