Hello!
I have found another option on how to restrict access to /admin without any other problems to other paths eg./SOGo.
Add the below piece of code in data/conf/nginx/site.ip-restrictions.custom in order to have it merged with the config that is already present. In the below example we are permitting the following IP Adddreses: 192.168.1.1-192.168.1.255.
if ($request_uri ~* "^/admin") {
set $admin_access 0;
}
if ($remote_addr ~* "^192.168\.1\.1\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$") {
set $admin_access 1;
}
if ($admin_access = 0) {
return 444;
}
NOTE: IP CIDRs(eg.192.168.1.0/24) won’t work because they will break the Mailcow routing for /admin/* eg. /admin/dashboard therefore we have to use regex.
Return code of nginx can be modified from 444 to 403 or whatever status code you want: HTTP_status_codes
If you want to grant permission for one or two IPs then you can use it like this:
"^192\.168\.1\.50$"
"^192\.168\.1\.(50|100)$"
If you want to grant permission to a whole subnet use the following:
"^192.168\.1\.1\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
@bogdanovser maybe you want to give this a try since I saw that you don’t really want to have a reverse proxy.
@gorby by doing this the reverse proxy won’t be needed anymore.