Caddy Rules NGINX

Hello All,

I have a problem to make NGINX rules work on caddy
Can you help me thanks :slight_smile:

1. Caddy version (caddy version):


2. How I run Caddy:

Unbuntu Machine, PHP CGI

a. System environment:


b. Command:

d. My complete Caddyfile or JSON config:

        location / { 
            try_files $uri $uri/ /index.php?$args;         
        location ~ /(knob|door|key) {
   		    deny all;
   		    return 404;
        location ~* /(knob|door|key|gem)/(.+)\.(jpg|jpeg|png|gif|css|js|svg|flv|mp3|jfif|wav|mp4|ogg|pdf|webm|json|webp|bmp)$ {
        	allow all;
    	location ~ /(knob|door|key|gem)/(.+)\.[^\.]+$ {
     		deny all;

3. The problem I’m having:

Converting htaccess from NGINX to caddy

Which version exactly? It often matters, you may be using an old version with known bugs, or less features. Run the caddy version command to find out.

That’s your Nginx config in that section.

What are you trying to do exactly? What have you tried so far? What do you have in your Caddyfile right now?

Please at least try to figure it out yourself, it’s the best way to learn. Make sure to read through the docs.

1 Like

Hello Sir,

Thanks for you response

Caddy v2.4.5

and i already tried this (it’s works) but others rules i don’t know how to

# TEST 1
@denied_folders path_regexp /(\.github|knob|door|key|backup.*|test.*)/.*$

respond @denied_folders "File Not Found" 404

but others i can’t success to make it
sorry i’m french

and my caddy file is too long, i just have a problem because i tried to make rules in caddy format but i can’t
others conf works very well and caddy is the best honestly

Are the docs inaccessible due to their language? I know they are only in English; translating to French is not something that has been on our radar. Can you use Google Translate to help?

As a hint, here are the docs for try_files: try_files (Caddyfile directive) — Caddy Documentation

Please give it a try, I hope Google Translate can help. Then let us know what you’ve tried.

Try_files is ok

my only problem is this :slight_smile:

        location ~* /(knob|door|key|gem)/(.+)\.(jpg|jpeg|png|gif|css|js|svg|flv|mp3|jfif|wav|mp4|ogg|pdf|webm|json|webp|bmp)$ {
        	allow all;
    	location ~ /(knob|door|key|gem)/(.+)\.[^\.]+$ {
     		deny all;

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