mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-06 19:47:00 +03:00
Merge pull request #442 from mchangrh/nginx-update
update nginx configs
This commit is contained in:
11
nginx/cors.conf
Normal file
11
nginx/cors.conf
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
if ($request_method = 'OPTIONS') {
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE';
|
||||||
|
add_header 'Access-Control-Allow-Headers', 'Content-Type'
|
||||||
|
# cache CORS for 24 hours
|
||||||
|
add_header 'Access-Control-Max-Age' 86400;
|
||||||
|
# return empty response for preflight
|
||||||
|
add_header 'Content-Type' 'text/plain; charset=UTF-8';
|
||||||
|
add_header 'Content-Length' 0;
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
7
nginx/error.conf
Normal file
7
nginx/error.conf
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 /error_message;
|
||||||
|
|
||||||
|
location = /error.html {
|
||||||
|
ssi on;
|
||||||
|
internal;
|
||||||
|
root /etc/nginx/error;
|
||||||
|
}
|
||||||
1
nginx/error/error.html
Normal file
1
nginx/error/error.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<!--# echo var="status"--> <!--# echo var="status_text"--> https://status.sponsor.ajay.app
|
||||||
15
nginx/error_map.conf
Normal file
15
nginx/error_map.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
map $status $status_text {
|
||||||
|
400 'Bad Request';
|
||||||
|
401 'Unauthorized';
|
||||||
|
403 'Forbidden';
|
||||||
|
404 'Not Found';
|
||||||
|
405 'Method Not Allowed';
|
||||||
|
408 'Request Timeout';
|
||||||
|
409 'Conflict';
|
||||||
|
429 'Too Many Requests';
|
||||||
|
500 'Internal Server Error';
|
||||||
|
502 'Bad Gateway';
|
||||||
|
503 'Service Unavailable';
|
||||||
|
504 'Gateway Timeout';
|
||||||
|
505 'HTTP Version Not Supported';
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
|
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
||||||
fastcgi_param QUERY_STRING $query_string;
|
|
||||||
fastcgi_param REQUEST_METHOD $request_method;
|
|
||||||
fastcgi_param CONTENT_TYPE $content_type;
|
|
||||||
fastcgi_param CONTENT_LENGTH $content_length;
|
|
||||||
|
|
||||||
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
|
||||||
fastcgi_param REQUEST_URI $request_uri;
|
|
||||||
fastcgi_param DOCUMENT_URI $document_uri;
|
|
||||||
fastcgi_param DOCUMENT_ROOT $document_root;
|
|
||||||
fastcgi_param SERVER_PROTOCOL $server_protocol;
|
|
||||||
fastcgi_param REQUEST_SCHEME $scheme;
|
|
||||||
fastcgi_param HTTPS $https if_not_empty;
|
|
||||||
|
|
||||||
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
|
|
||||||
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
|
|
||||||
|
|
||||||
fastcgi_param REMOTE_ADDR $remote_addr;
|
|
||||||
fastcgi_param REMOTE_PORT $remote_port;
|
|
||||||
fastcgi_param SERVER_ADDR $server_addr;
|
|
||||||
fastcgi_param SERVER_PORT $server_port;
|
|
||||||
fastcgi_param SERVER_NAME $server_name;
|
|
||||||
|
|
||||||
# PHP only, required if PHP was built with --enable-force-cgi-redirect
|
|
||||||
fastcgi_param REDIRECT_STATUS 200;
|
|
||||||
@@ -19,16 +19,15 @@ http {
|
|||||||
|
|
||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
include /etc/nginx/proxy.conf;
|
include /etc/nginx/proxy.conf;
|
||||||
include /etc/nginx/fastcgi.conf;
|
# error_map has to be at http level
|
||||||
## Custom MIME definition
|
include /etc/nginx/error_map.conf;
|
||||||
|
# Custom MIME definition
|
||||||
types {
|
types {
|
||||||
text/csv csv;
|
text/csv csv;
|
||||||
}
|
}
|
||||||
# keepalive settings
|
# keepalive settings
|
||||||
keepalive_requests 10;
|
keepalive_requests 10;
|
||||||
keepalive_timeout 5;
|
keepalive_timeout 5;
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Connection "";
|
|
||||||
access_log off;
|
access_log off;
|
||||||
#error_log /etc/nginx/logs/error.log warn;
|
#error_log /etc/nginx/logs/error.log warn;
|
||||||
error_log /dev/null crit;
|
error_log /dev/null crit;
|
||||||
@@ -70,15 +69,11 @@ http {
|
|||||||
server 10.0.0.3:4441;
|
server 10.0.0.3:4441;
|
||||||
#server 10.0.0.3:4442;
|
#server 10.0.0.3:4442;
|
||||||
}
|
}
|
||||||
upstream backend_OPTIONS {
|
|
||||||
server 10.0.0.3:4441;
|
|
||||||
}
|
|
||||||
upstream backend_db {
|
upstream backend_db {
|
||||||
server 10.0.0.4:4441;
|
server 10.0.0.4:4441;
|
||||||
#server 10.0.0.3:4441;
|
#server 10.0.0.3:4441;
|
||||||
#server 10.0.0.4;
|
#server 10.0.0.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
upstream backend_db_dl {
|
upstream backend_db_dl {
|
||||||
server 10.0.0.4;
|
server 10.0.0.4;
|
||||||
}
|
}
|
||||||
@@ -90,26 +85,7 @@ http {
|
|||||||
server {
|
server {
|
||||||
server_name sponsor.ajay.app api.sponsor.ajay.app;
|
server_name sponsor.ajay.app api.sponsor.ajay.app;
|
||||||
|
|
||||||
error_page 404 /404.html;
|
include /etc/nginx/error.conf;
|
||||||
#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;
|
|
||||||
#}
|
|
||||||
|
|
||||||
#proxy_send_timeout 120s;
|
|
||||||
|
|
||||||
#location @myerrordirective_500 {
|
|
||||||
# return 400 "Internal Server Error";
|
|
||||||
#}
|
|
||||||
#location @myerrordirective_502 {
|
|
||||||
# return 400 "Bad Gateway";
|
|
||||||
#}
|
|
||||||
#location @myerrordirective_504 {
|
|
||||||
# return 400 "Gateway Timeout";
|
|
||||||
#}
|
|
||||||
|
|
||||||
location /news {
|
location /news {
|
||||||
return 301 https://blog.ajay.app/sponsorblock;
|
return 301 https://blog.ajay.app/sponsorblock;
|
||||||
@@ -128,6 +104,7 @@ http {
|
|||||||
#access_log /etc/nginx/logs/requests.log no_ip buffer=64k;
|
#access_log /etc/nginx/logs/requests.log no_ip buffer=64k;
|
||||||
|
|
||||||
location /api/skipSegments {
|
location /api/skipSegments {
|
||||||
|
include /etc/nginx/cors.conf;
|
||||||
#return 200 "[]";
|
#return 200 "[]";
|
||||||
proxy_pass http://backend_$request_method;
|
proxy_pass http://backend_$request_method;
|
||||||
#proxy_cache CACHEZONE;
|
#proxy_cache CACHEZONE;
|
||||||
@@ -139,31 +116,35 @@ http {
|
|||||||
if ($request_method = POST) {
|
if ($request_method = POST) {
|
||||||
access_log /etc/nginx/logs/submissions.log user_agent buffer=64k;
|
access_log /etc/nginx/logs/submissions.log user_agent buffer=64k;
|
||||||
}
|
}
|
||||||
|
|
||||||
#proxy_read_timeout 6s;
|
#proxy_read_timeout 6s;
|
||||||
#proxy_next_upstream error timeout http_500 http_502;
|
#proxy_next_upstream error timeout http_500 http_502;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /api/getTopUsers {
|
location /api/getTopUsers {
|
||||||
|
include /etc/nginx/cors.conf;
|
||||||
proxy_pass http://backend_GET;
|
proxy_pass http://backend_GET;
|
||||||
proxy_cache CACHEZONE;
|
proxy_cache CACHEZONE;
|
||||||
proxy_cache_valid 20m;
|
proxy_cache_valid 20m;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /api/getTotalStats {
|
location /api/getTotalStats {
|
||||||
|
include /etc/nginx/cors.conf;
|
||||||
proxy_pass http://backend_GET;
|
proxy_pass http://backend_GET;
|
||||||
proxy_cache CACHEZONE;
|
proxy_cache CACHEZONE;
|
||||||
proxy_cache_valid 20m;
|
proxy_cache_valid 20m;
|
||||||
#return 200 "";
|
#return 204;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /api/getTopCategoryUsers {
|
location /api/getTopCategoryUsers {
|
||||||
|
include /etc/nginx/cors.conf;
|
||||||
proxy_pass http://backend_GET;
|
proxy_pass http://backend_GET;
|
||||||
proxy_cache CACHEZONE;
|
proxy_cache CACHEZONE;
|
||||||
proxy_cache_valid 20m;
|
proxy_cache_valid 20m;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /api/getVideoSponsorTimes {
|
location /api/getVideoSponsorTimes {
|
||||||
|
include /etc/nginx/cors.conf;
|
||||||
proxy_pass http://backend_GET;
|
proxy_pass http://backend_GET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,10 +160,11 @@ http {
|
|||||||
#proxy_buffering off;
|
#proxy_buffering off;
|
||||||
|
|
||||||
|
|
||||||
proxy_pass http://backend_db;
|
proxy_pass http://backend_db;
|
||||||
#alias /home/sbadmin/sponsor/docker/database-export/;
|
#alias /home/sbadmin/sponsor/docker/database-export/;
|
||||||
#return 307 https://rsync.sponsor.ajay.app$request_uri;
|
#return 307 https://rsync.sponsor.ajay.app$request_uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /database {
|
location /database {
|
||||||
proxy_pass http://backend_db;
|
proxy_pass http://backend_db;
|
||||||
#return 200 "Disabled for load reasons";
|
#return 200 "Disabled for load reasons";
|
||||||
@@ -207,6 +189,7 @@ http {
|
|||||||
#}
|
#}
|
||||||
|
|
||||||
location /api {
|
location /api {
|
||||||
|
include /etc/nginx/cors.conf;
|
||||||
proxy_pass http://backend_POST;
|
proxy_pass http://backend_POST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
client_max_body_size 10m;
|
proxy_set_header Connection "";
|
||||||
client_body_buffer_size 128k;
|
client_max_body_size 10m;
|
||||||
proxy_connect_timeout 10;
|
client_body_buffer_size 128k;
|
||||||
proxy_send_timeout 10;
|
proxy_connect_timeout 10;
|
||||||
proxy_read_timeout 10;
|
proxy_send_timeout 10;
|
||||||
#worker_shutdown_timeout 10;
|
proxy_read_timeout 10;
|
||||||
proxy_buffers 32 4k;
|
proxy_buffers 32 4k;
|
||||||
|
proxy_http_version 1.1;
|
||||||
@@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from "express";
|
|||||||
|
|
||||||
export function corsMiddleware(req: Request, res: Response, next: NextFunction): void {
|
export function corsMiddleware(req: Request, res: Response, next: NextFunction): void {
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
res.header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Accept");
|
|
||||||
res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS, DELETE");
|
res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS, DELETE");
|
||||||
|
res.header("Access-Control-Allow-Headers", "Content-Type");
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user