1

Topic: Restrict access to iredadmin NGINX

I saw "Restrict access to iredadmin NGINX" topic was closed (https://forum.iredmail.org/topic10831-i … nginx.html) and I reopened because I have tried the solution provided in previous topic and is not working.

Can anyone please help me here ?

here are the settings in  /etc/nginx/templates/iredadmin.tmpl

# Settings for iRedAdmin.

# static files under /iredadmin/static
location ~ ^/iredadmin/static/(.*) {
    alias /opt/www/iredadmin/static/$1;
}
# Python scripts
location ~ ^/iredadmin(.*) {
    rewrite ^/iredadmin(/.*)$ $1 break;
    include /etc/nginx/templates/hsts.tmpl;
    include uwsgi_params;
    uwsgi_pass 127.0.0.1:7791;
    uwsgi_param UWSGI_CHDIR /opt/www/iredadmin;
    uwsgi_param UWSGI_SCRIPT iredadmin;
    uwsgi_param SCRIPT_NAME /iredadmin;

    # Access control
#     allow 127.0.0.1;
#     allow 192.168.3.223;
#     allow 192.168.0.0/22;
#     deny all;
}
# iRedAdmin: redirect /iredadmin to /iredadmin/
location = /iredadmin {
    rewrite ^ /iredadmin/;
}
# Handle newsletter-style subscription/unsubscription supported in iRedAdmin-Pro.
location ~ ^/newsletter/ {
    rewrite /newsletter/(.*) /iredadmin/newsletter/$1 last;
}


If de-comment in Access control block will block access.
Thank you in advance.

I would like to fix this instead of working with .htaccess.

----------------------------------------------------------------------------------------------------------------
- iRedMail version 1.5.1 :
- Deployed with installer
- Linux/Ubuntu 20.04
- Nginx
- Stored mail accounts LDAP

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Restrict access to iredadmin NGINX

If you want to deny access for everyone except localhost, then uncomment "allow 127.0.0.1;" and "deny all;". If you want to deny all access then uncomment only "deny all;". Don't forget to reload nginx after modifying the file.