Translate nginx rules snippet in Caddyfile

1. The problem I’m having:

I have a snippet file for nginx. rhymix/common/manual/server_config/rhymix-nginx.conf at master · rhymix/rhymix ( I have to apply this rule using caddyfile. I don’t know how to change it in caddyfile format.

2. Error messages and/or full log output:

There is no any error log

3. Caddy version:

v2.7.5 h1:HoysvZkLcN2xJExEepaFHK92Qgs7xAiCFydN5x5Hs6Q=

4. How I installed and ran Caddy:

Using apt, ppa

a. System environment:

OS: Ubuntu 22.04.3 LTS aarch64
Host: KVM Virtual Machine virt-4.2
Kernel: 5.15.0-1051-realtime

b. Command:

Please use the preview pane to ensure it looks nice.

c. Service/unit/compose file:

Please use the preview pane to ensure it looks nice.

d. My complete Caddy config: {
    root * /var/pplus
    php_fastcgi unix//run/php/php-fpm.sock

5. Links to relevant resources:

RewriteEngine On

# block direct access to templates, XML schema files, config files, dotfiles, environment, etc.
RewriteCond %{REQUEST_URI} !/modules/editor/(skins|styles)/
RewriteRule ^(addons|common/tpl|files/ruleset|(m\.)?layouts|modules|plugins|themes|widgets|widgetstyles)/.+\.(html|xml|blade\.php)$ - [L,F]
RewriteRule ^files/(attach|config|cache)/.+\.(ph(p|t|ar)?[0-9]?|p?html?|cgi|pl|exe|[aj]spx?|inc|bak)$ - [L,F]
RewriteRule ^files/(env|member_extra_info/(new_message_flags|point))/ - [L,F]
RewriteRule ^(\.git|\.ht|\.travis|codeception\.|composer\.|Gruntfile\.js|package\.json|CONTRIBUTING|COPYRIGHT|LICENSE|README) - [L,F]

# static files
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.+)/(addons|files|layouts|m\.layouts|modules|widgets|widgetstyles)/(.*) ./$2/$3 [L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.+)\.min\.(css|js)$ ./$1.$2 [L]

# all other short URLs
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule . index.php [L]

this is .htaccess file that working same with nginx config.

I don’t have time to convert all of those for you, as a volunteer.

You’ll need to use a combination of named request matchers (mostly path_regexp) with directives like error

Are you sure you actually need all those rules though? From their comments it looks like many of them are only needed for “legacy”. If you’re using a new deployment of that CMS, you probably don’t need them.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.