map $geoip2_data_country_code $allowed_country {
default no;
DE yes;
}
location /NURDE {
if ($allowed_country = no) {
return 451; /* 451 Unavailable For Legal Reasons */
}
}
Deine NGinx-Konfiguration ohne GeoIP steht ja schon, nehme ich an. Installiert hast du vorgefertigte Packages für GeoIP2 schon.
Unter https://dev.iachieved.it/iachievedit/geoip2-and-nginx/ ist viel zu Konfiguration beschrieben.
[/CODE]
http {
geoip2 /usr/share/GeoIP/GeoLite2-Country.mmdb {
$geoip2_data_country_code country iso_code;
}
map $geoip2_data_country_code $allowed_country {
default no;
DE yes;
}
...
server {
listen xxxxxxx:443 ssl http2;
listen [xxxxxxx]:443 ssl http2;
server_name xxxxxxx;
ssl_protocols TLSv1.2;
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256;
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
ssl_ecdh_curve secp384r1;
ssl_prefer_server_ciphers on;
ssl_certificate /etc/letsencrypt/live/xxxxxx/xxxxxxx.crt;
ssl_certificate_key /etc/letsencrypt/live/xxxxxx/xxxxxxx.key;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/letsencrypt/live/xxxxxx/xxxxxxx.crt;
include /etc/nginx/acme.conf;
access_log /var/logs/sayanee-xxxxxxx-access.log combined;
error_log /var/logs/sayanee-xxxxxxx-error.log error;
root /home/webs/sayanee/xxxxxxx/;
location / {
index index.php index.html index.htm;
}
location ~ ^(.+?\.php)(/.*)?$ {
try_files /4b52a9cc6005e2879470515314ce542d.htm @php;
}
location @php {
try_files $1 = 404;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
fastcgi_param SCRIPT_FILENAME $document_root$1;
fastcgi_param PATH_INFO $2;
fastcgi_param HTTPS on;
fastcgi_pass unix:/var/run/1-xxxxxxx-php-fpm.socket;
fastcgi_index index.php;
}
location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
expires max;
log_not_found off;
access_log off;
}
location = /robots.txt {
access_log off;
log_not_found off;
}
location /moderator {
if ($allowed_country = no) {
return 451; /* 451 Unavailable For Legal Reasons */
}
}
nginx: [emerg] unexpected "}" in /etc/nginx/sites-enabled/xxxxx.conf:59
nginx: configuration file /etc/nginx/nginx.conf test failed
location /moderator {
if ($allowed_country = no) {
return 451; /* 451 Unavailable For Legal Reasons */
}
wenn ich mich nicht verzählt habe, fehlt hierein schließendes }Code:location /moderator { if ($allowed_country = no) { return 451; /* 451 Unavailable For Legal Reasons */ }
Hilfreich ist da immer ein Editor, der in der Lage ist, korrespondierende Klammerpaare anzuzeigen - das müsste AFAIK sogar vi hinbekommen.
Inwiefern sperrst du dich dann aus?Aber so wie ich es wollte, geht es gar nicht, sperre mich selbst damit aus
Inwiefern sperrst du dich dann aus?
2019/02/24 16:01:09 [error] 18458#18458: *1 directory index of "/home/webs/sayanee/xxxxx/moderator/" is forbidden
user www-data;
worker_processes auto;
pid /run/nginx.pid;
#include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 4000;
multi_accept on;
use epoll;
}
http {
geoip2 /usr/share/GeoIP/GeoLite2-Country.mmdb {
$geoip2_data_country_code country iso_code;
}
map $geoip2_data_country_code $allowed_country {
default no;
DE yes;
}
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
server_tokens off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 1d;
ssl_session_tickets off;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
access_log off;
error_log /var/log/nginx/error.log warn;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;
server {
limit_conn conn_limit_per_ip 10;
limit_req zone=req_limit_per_ip burst=10 nodelay;
}
reset_timedout_connection on;
send_timeout 2;
keepalive_requests 100000;
client_body_buffer_size 128k;
client_header_buffer_size 3m;
large_client_header_buffers 4 256k;
client_body_timeout 3m;
client_header_timeout 3m;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
add_header "X-UA-Compatible" "IE=Edge";
add_header "X-XSS-Protection" "1; mode=block";
# include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Idee: Wenn du bestimmte eingeloggte Nutzer wie dich als Amin nicht blocken willst, müsstest du eine Authentifizierung per SSL-Client-Zertifikat hinzufügen.
http://blog.nategood.com/client-side-certificate-authentication-in-ngi
http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_verify_client
We use essential cookies to make this site work, and optional cookies to enhance your experience.