SponsorBlockServer/nginx/nginx.conf

318 lines
9 KiB
Nginx Configuration File
Raw Normal View History

2022-02-12 06:49:21 +01:00
worker_processes 2;
worker_rlimit_nofile 500000;
worker_shutdown_timeout 10;
2021-01-23 18:48:22 +01:00
events {
2022-02-12 06:49:21 +01:00
worker_connections 100000; # Default: 1024
#use epoll;
#multi_accept on;
2021-01-23 18:48:22 +01:00
}
http {
2021-08-27 23:59:40 +02:00
log_format no_ip '$remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" "$gzip_ratio"';
2021-08-27 23:59:40 +02:00
log_format user_agent '[$time_local] '
'"$http_referer" "$http_user_agent" "$gzip_ratio"';
2022-01-16 19:03:02 +01:00
#limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;
2022-02-12 06:49:21 +01:00
limit_req_log_level warn;
include /etc/nginx/mime.types;
include /etc/nginx/proxy.conf;
2022-03-04 01:53:31 +01:00
# error_map has to be at http level
include /etc/nginx/error_map.conf;
# Custom MIME definition
2021-10-06 05:31:05 +02:00
types {
text/csv csv;
}
# keepalive settings
2022-02-12 06:49:21 +01:00
#keepalive_requests 10;
2022-03-04 01:53:31 +01:00
keepalive_timeout 10s;
http2_idle_timeout 20s; # replaced by keepalive_timeout in 1.19.7
2022-02-12 06:49:21 +01:00
2021-12-29 23:33:00 +01:00
access_log off;
2022-01-16 19:03:02 +01:00
#error_log /etc/nginx/logs/error.log warn;
2021-12-29 23:33:00 +01:00
error_log /dev/null crit;
upstream backend_GET {
2022-02-16 02:27:04 +01:00
least_conn;
2021-12-20 03:24:54 +01:00
2022-02-12 06:49:21 +01:00
#keepalive 5;
#server localhost:4441;
#server localhost:4442;
#server localhost:4443;
#server localhost:4444;
#server localhost:4445;
#server localhost:4446;
#server localhost:4447;
#server localhost:4448;
2022-04-14 07:57:23 +02:00
#server 10.0.0.4:4441 max_fails=25 fail_timeout=20s;
2022-03-04 01:58:03 +01:00
#server 10.0.0.3:4441 max_fails=25 fail_timeout=20s;
#server 10.0.0.3:4442 max_fails=25 fail_timeout=20s;
2022-03-04 01:58:03 +01:00
server 10.0.0.5:4441 max_fails=25 fail_timeout=20s;
server 10.0.0.5:4442 max_fails=25 fail_timeout=20s;
2021-10-27 02:54:25 +02:00
2022-03-04 01:58:03 +01:00
server 10.0.0.6:4441 max_fails=25 fail_timeout=20s;
server 10.0.0.6:4442 max_fails=25 fail_timeout=20s;
2021-12-20 03:13:29 +01:00
2022-03-04 01:58:03 +01:00
server 10.0.0.9:4441 max_fails=25 fail_timeout=20s;
server 10.0.0.9:4442 max_fails=25 fail_timeout=20s;
2021-11-21 17:40:39 +01:00
2022-03-04 01:58:03 +01:00
server 10.0.0.12:4441 max_fails=25 fail_timeout=20s;
server 10.0.0.12:4442 max_fails=25 fail_timeout=20s;
2022-03-04 01:53:31 +01:00
2022-03-04 01:58:03 +01:00
server 10.0.0.10:4441 max_fails=25 fail_timeout=20s;
server 10.0.0.10:4442 max_fails=25 fail_timeout=20s;
2022-03-04 01:53:31 +01:00
2022-03-04 01:58:03 +01:00
server 10.0.0.13:4441 max_fails=25 fail_timeout=20s;
server 10.0.0.13:4442 max_fails=25 fail_timeout=20s;
2022-03-30 20:15:44 +02:00
2022-04-14 07:18:48 +02:00
server 10.0.0.14:4441 max_fails=25 fail_timeout=20s;
server 10.0.0.14:4442 max_fails=25 fail_timeout=20s;
2022-03-30 20:15:44 +02:00
server 10.0.0.11:4441 max_fails=25 fail_timeout=20s;
server 10.0.0.11:4442 max_fails=25 fail_timeout=20s;
2022-04-27 20:19:14 +02:00
server 10.0.0.16:4441 max_fails=25 fail_timeout=20s;
server 10.0.0.16:4442 max_fails=25 fail_timeout=20s;
2022-05-05 15:12:12 +02:00
2022-06-01 19:53:10 +02:00
#server 10.0.0.17:4441 max_fails=25 fail_timeout=20s;
#server 10.0.0.17:4442 max_fails=25 fail_timeout=20s;
2022-02-12 06:49:21 +01:00
#server 134.209.69.251:80 backup;
#server 116.203.32.253:80 backup;
#server 116.203.32.253:80;
2021-01-23 18:48:22 +01:00
}
upstream backend_POST {
#server localhost:4441;
#server localhost:4442;
2022-03-29 19:08:12 +02:00
server 10.0.0.3:4441 max_fails=25 fail_timeout=15s;
2022-04-14 07:57:23 +02:00
server 10.0.0.4:4441 max_fails=25 fail_timeout=15s;
#server 10.0.0.3:4442;
2021-01-23 18:48:22 +01:00
}
upstream backend_db {
2022-02-16 02:27:04 +01:00
server 10.0.0.4:4441 max_fails=1 fail_timeout=3s;
#server 10.0.0.3:4441;
#server 10.0.0.4;
}
2021-12-13 01:41:16 +01:00
upstream backend_db_dl {
server 10.0.0.4;
2021-04-13 03:04:02 +02:00
}
2021-01-23 18:48:22 +01:00
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHEZONE:10m inactive=60m max_size=400m;
proxy_cache_key "$scheme$request_method$host$request_uri";
add_header X-Cache $upstream_cache_status;
server {
server_name sponsor.ajay.app api.sponsor.ajay.app;
include /etc/nginx/error.conf;
2022-03-07 18:39:38 +01:00
set_real_ip_from 10.0.0.0/24;
real_ip_header proxy_protocol;
location /news {
return 301 https://blog.ajay.app/sponsorblock;
}
location /viewer {
return 301 https://sb.ltn.fi;
}
location /test/ {
2021-10-27 04:00:32 +02:00
# return 404 "";
2022-03-17 17:31:09 +01:00
proxy_pass http://10.0.0.4:4445/;
#proxy_pass https://sbtest.etcinit.com/;
}
#access_log /etc/nginx/logs/requests.log no_ip buffer=64k;
2021-12-05 05:06:31 +01:00
location /api/skipSegments {
2022-01-07 00:49:49 +01:00
include /etc/nginx/cors.conf;
#return 200 "[]";
proxy_pass http://backend_$request_method;
2022-06-01 20:24:58 +02:00
proxy_cache CACHEZONE;
proxy_cache_valid 20s;
2022-01-16 19:03:02 +01:00
#limit_req zone=mylimit;
2021-12-05 05:06:31 +01:00
#access_log /etc/nginx/logs/download.log no_ip;
gzip on;
if ($request_method = POST) {
access_log /etc/nginx/logs/submissions.log user_agent buffer=64k;
}
2021-12-13 01:41:16 +01:00
#proxy_read_timeout 6s;
#proxy_next_upstream error timeout http_500 http_502;
}
location /api/getTopUsers {
2022-01-07 00:49:49 +01:00
include /etc/nginx/cors.conf;
proxy_pass http://backend_GET;
proxy_cache CACHEZONE;
proxy_cache_valid 20m;
}
location /api/getTotalStats {
2022-01-07 00:49:49 +01:00
include /etc/nginx/cors.conf;
2022-02-12 06:49:21 +01:00
proxy_pass http://backend_POST;
proxy_cache CACHEZONE;
2021-11-21 17:40:39 +01:00
proxy_cache_valid 20m;
#return 204;
}
2022-01-03 04:28:22 +01:00
location /api/getTopCategoryUsers {
2022-01-07 00:49:49 +01:00
include /etc/nginx/cors.conf;
2022-02-12 06:49:21 +01:00
proxy_pass http://backend_POST;
2022-01-03 04:28:22 +01:00
proxy_cache CACHEZONE;
proxy_cache_valid 20m;
}
location /api/getVideoSponsorTimes {
2022-01-07 00:49:49 +01:00
include /etc/nginx/cors.conf;
proxy_pass http://backend_GET;
}
2022-03-29 20:14:53 +02:00
location /api/isUserVIP {
include /etc/nginx/cors.conf;
proxy_pass http://backend_GET;
}
location /download/ {
#access_log /etc/nginx/logs/download.log no_ip buffer=64k;
gzip on;
2021-12-22 23:26:04 +01:00
proxy_max_temp_file_size 0;
#proxy_cache CACHEZONE;
#proxy_cache_valid 20m;
#proxy_http_version 1.0;
2021-12-13 01:41:16 +01:00
#gzip_types text/csv;
#gzip_comp_level 1;
2021-12-22 23:26:04 +01:00
#proxy_buffering off;
proxy_pass http://backend_db;
#alias /home/sbadmin/sponsor/docker/database-export/;
2021-12-22 23:26:04 +01:00
#return 307 https://rsync.sponsor.ajay.app$request_uri;
}
location /database {
proxy_pass http://backend_db;
#return 200 "Disabled for load reasons";
}
location = /database.db {
return 404 "Sqlite database has been replaced with csv exports at https://sponsor.ajay.app/database. Sqlite exports might come back soon, but exported at longer intervals.";
#alias /home/sbadmin/sponsor/databases/sponsorTimes.db;
#alias /home/sbadmin/test-db/database.db;
}
#location = /database/sponsorTimes.csv {
# alias /home/sbadmin/sponsorTimes.csv;
#}
#location /api/voteOnSponsorTime {
# return 200 "Success";
#}
2021-04-18 04:49:05 +02:00
#location /api/viewedVideoSponsorTime {
# return 200 "Success";
#}
location /api {
2022-01-07 00:49:49 +01:00
include /etc/nginx/cors.conf;
proxy_pass http://backend_POST;
}
location / {
root /home/sbadmin/SponsorBlockSite/public-prod;
2022-01-17 00:18:46 +01:00
error_page 404 /404.html;
}
2021-12-05 05:06:31 +01:00
listen [::]:443 default_server ssl http2 ipv6only=on backlog=323999;
2022-02-12 06:49:21 +01:00
listen 443 default_server ssl http2 reuseport backlog=3000999; # managed by Certbot
2022-03-07 18:39:38 +01:00
listen 4443 default_server ssl http2 proxy_protocol reuseport backlog=3000999;
#listen 443 http3 reuseport;
#ssl_protocols TLSv1.2 TLSv1.3;
2022-03-07 18:39:38 +01:00
listen 8081 proxy_protocol;
2022-03-08 19:28:59 +01:00
port_in_redirect off;
2022-02-12 06:49:21 +01:00
ssl_certificate /home/sbadmin/certs/cert.pem;
ssl_certificate_key /home/sbadmin/certs/key.pem;
#ssl_certificate /etc/letsencrypt/live/sponsor.ajay.app-0001/fullchain.pem; # managed by Certbot
#ssl_certificate_key /etc/letsencrypt/live/sponsor.ajay.app-0001/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
2021-04-18 21:10:43 +02:00
server {
server_name cdnsponsor.ajay.app;
error_page 404 /404.html;
2021-08-24 21:10:57 +02:00
#location /database/ {
# alias /home/sbadmin/sponsor/docker/database-export/;
#}
2021-08-24 21:10:57 +02:00
#location /download/ {
# alias /home/sbadmin/sponsor/docker/database-export/;
#}
2021-08-24 21:10:57 +02:00
location / {
root /home/sbadmin/SponsorBlockSite/public-prod;
}
2021-08-24 21:10:57 +02:00
listen 443 ssl; # managed by Certbot
2022-02-12 06:49:21 +01:00
ssl_certificate /home/sbadmin/certs/cert.pem;
ssl_certificate_key /home/sbadmin/certs/key.pem;
#ssl_certificate /etc/letsencrypt/live/sponsor.ajay.app-0001/fullchain.pem; # managed by Certbot
#ssl_certificate_key /etc/letsencrypt/live/sponsor.ajay.app-0001/privkey.pem; # managed by Certbot
2021-08-27 23:59:40 +02:00
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
2021-08-24 21:10:57 +02:00
server {
access_log off;
2021-08-24 21:10:57 +02:00
2022-02-12 06:49:21 +01:00
return 301 https://$host$request_uri;
2021-08-24 21:10:57 +02:00
2021-11-21 17:40:39 +01:00
listen [::]:80 ipv6only=on;
2022-03-07 18:39:38 +01:00
listen 8080 proxy_protocol;
listen 80;
2022-02-12 06:49:21 +01:00
server_name sponsor.ajay.app api.sponsor.ajay.app, cdnsponsor.ajay.app, wiki.sponsor.ajay.app;
return 404; # managed by Certbot
}
2021-08-24 21:10:57 +02:00
server {
server_name wiki.sponsor.ajay.app; # managed by Certbot
2021-10-03 21:16:05 +02:00
2022-02-12 06:49:21 +01:00
location /.well-known/ {
root /home/sbadmin/SponsorBlockSite/public-prod;
}
2021-10-03 21:16:05 +02:00
location ~* ^/index.php/(?<pagename>.*)$ {
return 301 /w/$pagename;
}
location / {
proxy_pass http://10.0.0.3:8080;
}
2022-03-17 17:30:00 +01:00
port_in_redirect off;
2021-12-05 05:06:31 +01:00
listen [::]:443 ssl http2;
listen 443 ssl http2; # managed by Certbot
2022-03-07 18:39:38 +01:00
listen 8081 proxy_protocol;
#listen 443 http3 reuseport;
#ssl_protocols TLSv1.2 TLSv1.3;
#listen 80;
2022-02-12 06:49:21 +01:00
ssl_certificate /home/sbadmin/certs/cert.pem;
ssl_certificate_key /home/sbadmin/certs/key.pem;
#ssl_certificate /etc/letsencrypt/live/sponsor.ajay.app-0001/fullchain.pem; # managed by Certbot
#ssl_certificate_key /etc/letsencrypt/live/sponsor.ajay.app-0001/privkey.pem; # managed by Certbot
2021-08-27 23:59:40 +02:00
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
2021-08-24 21:10:57 +02:00
}