Before to test, I have some attempts to translate NGINX conf to Caddyfile syntax into Caddyfile. Below, the NGINX and Caddy syntax, respectively:
- path /app
location ~ /app/ {
deny all;
}
Attempt 01
rewrite {
if {path} starts_with app
status 403
}
Attempt 02
# Is it better than rewrite above?
status 403 {
/app
}
- path /Assets inside /app
location ~ /app/bundles/.*/Assets/ {
allow all;
access_log off;
}
rewrite {
if {path} start_with app
if {path} has Assets
status 200
}
- All PHP files inside themes path
location ~* ^/themes/(.*)\.php {
deny all;
}
rewrite {
ext .php
if {path} match /themes
# match or has?
status 403
}
- Prevent access the following files extensions
location ~* /(.*)\.(?:markdown|md|twig|yaml|yml|ht|htaccess|ini)$ {
deny all;
access_log off;
log_not_found off;
}
rewrite {
ext .markdown .md .twig .yaml .yml .ht .htaccess .ini
status 403
}
- Prevent access for some js/json specific files
location ~* (Gruntfile|package|composer)\.(js|json)$ {
deny all;
access_log off;
log_not_found off;
}
rewrite {
ext .js .json
if {file} match (Gruntfile|package|composer)
status 403
}
I am not sure about to handle with ~
and/or ~*
from NGINX. Some considerations? Tips? Any appointment will be appreciated. The intention is really understand the better way. For now, I have many tabs from Caddy Docs opened. I really want to learn
=> Note:
About Mautic rewrite, Iโm using the following only:
rewrite {
to {path} {path}/ /index.php/{query}
}
Works like a charm. The /index.php/
removed.
Thank you very much.