mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Merge branch 'master' of https://github.com/ajayyy/SponsorBlockServer
This commit is contained in:
commit
10fa36ccf0
1 changed files with 158 additions and 0 deletions
158
nginx/nginx.conf
Normal file
158
nginx/nginx.conf
Normal file
|
@ -0,0 +1,158 @@
|
|||
worker_processes 8;
|
||||
worker_rlimit_nofile 8192;
|
||||
|
||||
events {
|
||||
worker_connections 32768; ## Default: 1024
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
include /etc/nginx/proxy.conf;
|
||||
include /etc/nginx/fastcgi.conf;
|
||||
|
||||
upstream backend_GET {
|
||||
least_conn;
|
||||
server localhost:4442;
|
||||
server localhost:4443;
|
||||
server localhost:4444;
|
||||
server localhost:4445;
|
||||
server localhost:4446;
|
||||
#server localhost:4447;
|
||||
#server localhost:4448;
|
||||
}
|
||||
upstream backend_POST {
|
||||
server localhost:4441;
|
||||
}
|
||||
|
||||
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHEZONE:10m inactive=60m max_size=40m;
|
||||
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;
|
||||
|
||||
error_page 404 /404.html;
|
||||
error_page 500 @myerrordirective_500;
|
||||
error_page 502 @myerrordirective_502;
|
||||
error_page 504 @myerrordirective_504;
|
||||
#location = /404 {
|
||||
# root /home/sbadmin/caddy/SponsorBlockSite/public-prod;
|
||||
# internal;
|
||||
#}
|
||||
|
||||
location @myerrordirective_500 {
|
||||
return 502 "Internal Server Error";
|
||||
}
|
||||
location @myerrordirective_502 {
|
||||
return 502 "Bad Gateway";
|
||||
}
|
||||
location @myerrordirective_504 {
|
||||
return 502 "Gateway Timeout";
|
||||
}
|
||||
|
||||
|
||||
location = /news {
|
||||
return 301 https://blog.ajay.app/sponsorblock;
|
||||
}
|
||||
|
||||
location /invidious/ {
|
||||
proxy_pass https://invidious.fdn.fr/;
|
||||
}
|
||||
|
||||
location /test/ {
|
||||
proxy_pass http://localhost:4440/;
|
||||
#proxy_pass https://sbtest.etcinit.com/;
|
||||
}
|
||||
|
||||
location /api/skipSegments {
|
||||
proxy_pass http://backend_$request_method;
|
||||
}
|
||||
|
||||
location /api/getTopUsers {
|
||||
proxy_pass http://backend_GET;
|
||||
proxy_cache CACHEZONE;
|
||||
proxy_cache_valid 20m;
|
||||
}
|
||||
|
||||
location /api/getTotalStats {
|
||||
proxy_pass http://backend_GET;
|
||||
}
|
||||
|
||||
|
||||
location /api/getVideoSponsorTimes {
|
||||
proxy_pass http://backend_GET;
|
||||
}
|
||||
|
||||
location =/database.db {
|
||||
alias /home/sbadmin/sponsor/databases/sponsorTimes.db;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://backend_POST;
|
||||
}
|
||||
|
||||
location / {
|
||||
root /home/sbadmin/caddy/SponsorBlockSite/public-prod;
|
||||
|
||||
### CORS
|
||||
if ($request_method = 'OPTIONS') {
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
#
|
||||
# Custom headers and headers various browsers *should* be OK with but aren't
|
||||
#
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
||||
#
|
||||
# Tell client that this pre-flight info is valid for 20 days
|
||||
#
|
||||
add_header 'Access-Control-Max-Age' 1728000;
|
||||
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
||||
add_header 'Content-Length' 0;
|
||||
return 204;
|
||||
}
|
||||
if ($request_method = 'POST') {
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
|
||||
}
|
||||
if ($request_method = 'GET') {
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
listen 443 ssl; # managed by Certbot
|
||||
ssl_certificate /etc/letsencrypt/live/sponsor.ajay.app/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/sponsor.ajay.app/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
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
server {
|
||||
if ($host = api.sponsor.ajay.app) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
if ($host = sponsor.ajay.app) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
listen 80;
|
||||
server_name sponsor.ajay.app api.sponsor.ajay.app;
|
||||
return 404; # managed by Certbot
|
||||
|
||||
|
||||
|
||||
|
||||
}}
|
Loading…
Reference in a new issue