I have read nginx configuration documentation and I have some questions:
1) I see that Password protect administrator feature/button is not enabled/displayed anymore. So how to add .htpasswd protection as previously? what is your advice ?
Add a directive like this to every nginx vhost?
location / {
try_files $uri $uri/ =404;
auth_basic "Authentification needed";
auth_basic_user_file /var/www/my_website/administrator/.htpasswd;
}
2) As nginx does not use .htaccess files, I have added this directive into my nginx configuration :
# deny running scripts inside writable directories
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}
Previously, every directory tmp, logs, images had an .htaccess file to do that..like this :
<Files *.php>
Deny from all
</Files>
So now, this .htaccess file is not necessary ?
3) About nginx configuration maker : I don't want to add custom file to website root directory and I prefer using the second option you described : adding Security Enhanced & Highly Optimized NginX Configuration File for Joomla to nginx website vhost.
So this is correct (include security conf line) ?
server {
listen 80;
listen [::]:80;
server_name my_website.com;
return 301 https://www.$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.my_website.com my_website.com;
root /var/www/my_website;
index index.html index.htm index.php;
access_log /var/log/nginx/my_website.access_log;
error_log /var/log/nginx/my_website.error_log info;
include /etc/nginx/conf/security.conf; #custom file generated by admin tools nginx configuration maker
ssl_certificate /etc/letsencrypt/live/my_website.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/my_website.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/my_website.com/chain.pem;
include /etc/nginx/conf/ssl.conf;
}
4) I have added modsecurity to nginx with owasp-modsecurity-crs-3.0.0 rules.
Do you think these rules are useful/necessary if I use admin tools custom file generated by admin tools nginx configuration maker ?
Many thanks for your help
L.