Админ-панель почтового Web-клиента доступен по адресу: https://domain?admin
Чтобы ограничить доступ к данной станицы определенным IP, нужно внести изменения в файлы конфигураций:
1 | nano /etc/nginx/conf.d/default.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | server { listen 80; server_name _; server_tokens off; location /.well-known/acme-challenge/ { root /var/www/certbot; } location / { return 301 https://$host$request_uri; } } server { listen 443 ssl; server_name _; server_tokens off; ssl_certificate /etc/letsencrypt/live/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; if ($args ~ admin){ rewrite ^(.*)$ /admin/ break; } location /admin/{ include /etc/nginx/allow.conf; deny all; rewrite ^(.*)$ /?admin break; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Https-Protocol $ssl_protocol; proxy_pass http://172.16.0.25:8080; } location / { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Https-Protocol $ssl_protocol; proxy_pass http://172.16.0.25:8080; } } |
также нужно создать файл /etc/nginx/allow.conf
1 | nano /etc/nginx/allow.conf |
и задать список IP, которым мы разрешим доступ:
1 2 | allow 1.2.3.4; #Comment allow 1.2.3.0/24 #Comment |
Остальные примеры использования allow можно посмотреть здесь http://nginx.org/ru/docs/http/ngx_http_access_module.html
Проверяем конфигурацию nginx:
nginx -t
перезагружаем конфигурацию:
service nginx reload
Оставить комментарий