chores: nginx configuration for server and service
This commit is contained in:
commit
443f3a7f73
2 changed files with 62 additions and 0 deletions
40
conf/nginx.conf
Normal file
40
conf/nginx.conf
Normal file
|
@ -0,0 +1,40 @@
|
|||
load_module /usr/lib/nginx/modules/ngx_http_geoip2_module.so;
|
||||
|
||||
user nginx;
|
||||
worker_processes 1;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
#gzip on;
|
||||
geoip2 /var/lib/GeoIP/GeoLite2-Country.mmdb {
|
||||
$geoip2_data_country_iso_code country iso_code;
|
||||
}
|
||||
|
||||
map $geoip2_data_country_iso_code $allowed_country {
|
||||
default yes;
|
||||
BD no;
|
||||
}
|
||||
log_format main '$geoip2_data_country_iso_code $remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
}
|
22
conf/site.conf
Normal file
22
conf/site.conf
Normal file
|
@ -0,0 +1,22 @@
|
|||
server {
|
||||
# Block forbidden country
|
||||
default_type application/json;
|
||||
if ($allowed_country = no) {
|
||||
return 444 '{"code":"444", "message": "Blocked"}';
|
||||
}
|
||||
|
||||
location / {
|
||||
return 200 '{"code":"100", "message": "Not Blocked"}';
|
||||
}
|
||||
error_page 400 404 405 =200 @40*_json;
|
||||
|
||||
location @40*_json {
|
||||
return 200 '{"code":"1", "message": "Not Found"}';
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 =200 @50*_json;
|
||||
|
||||
location @50*_json {
|
||||
return 200 '{"code":"1", "message": "Unknown Error"}';
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue