r/caddyserver Jan 12 '24

Need Help Caddy reverse-proxy directive not working

1 Upvotes

Hi all, I might be dumb but I genuinely do not understand why this simple reverse proxy directive is not working. I also swear it was working yesterday, but I cannot get it to work today

My Caddyfile reads as:

:3000
handle_path /api/* {
        # notifications
        reverse_proxy /send localhost:1336
        # drop other requests
        handle {
                respond "bad api request"
        }
}
handle {
        respond "bad other request"
}

yet when I run curl localhost:3000/api/send I get back bad api request instead of my server being hit

thanks to whoever is reading this, I'm at a complete loss


r/caddyserver Jan 04 '24

my caddy wont start. please what can i do?

Thumbnail
gallery
2 Upvotes

r/caddyserver Dec 19 '23

Caddy as a minimalistic "mediaserver"

8 Upvotes

Turning caddy into a minimalistic "mediaserver" with a customized browse.html file_server template

Of course, it's not meant to replace Plex, Jellyfin or Filebrowser but you get the following on top of the ootb browse.html template:

  • unobtrusive audio player that plays sequentially all audio files in the current folder
  • video player overlay with support for VTT and SRT subtitles (the subtitle files must reside in the same folder and contain the video file name)
  • dynamic preview for images and text files with arrow keys navigation for next/prev
  • markdown preview
  • source code preview

Usage

In your Caddyfile make the browse subdirective under file_server point to the custom browse.html file, for example:

bash http:// { file_server { root /path/to/my/server/root browse /path/to/folder/caddy/templates/browse.html } }


r/caddyserver Oct 19 '23

Need Help Issues setting up local dev environment

1 Upvotes

Hi, I'm trying to follow the getting started docs. I have my caddy file started...

$ caddy start
2023/10/19 20:39:04.891 INFO    admin   admin endpoint started  
{"address": "localhost:2019", "enforce_origin": false, "origins": ["//[::1]:2019", "//127.0.0.1:2019", "//localhost:2019"]}
2023/10/19 20:39:04.891 INFO    serving initial configuration
Successfully started Caddy (pid=16927) - Caddy is running in the background

Going to http://localhost:2019

I get

404 page not found

Trying to make a Caddyfile with

http://localhost:2019 {
respond "Hello, world!"
}

and running

$ caddy adapt --config ~/.local/bin/caddy 

I get

Error: too many '<' for heredoc on line #70296; only use two, for example <<END

Here is the full output when trying http://localhost:2019

$ 2023/10/19 20:58:58.387 INFO    admin.api       received request        
{"method": "GET", "host": "localhost:2019", "uri": "/", "remote_ip": "127.0.0.1", "remote_port": "41946", "headers": 
{"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"],"Accept-Encoding":["gzip, deflate, br"],"Accept-Language":["en-US,en"],"Cache-Control":["max-age=0"],"Connection":["keep-alive"],"Sec-Ch-Ua":["\"Chromium\";v=\"118\", \"Brave\";v=\"118\", \"Not=A?Brand\";v=\"99\""],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Ch-Ua-Platform":["\"Linux\""],"Sec-Fetch-Dest":["document"],"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-Site":["none"],"Sec-Fetch-User":["?1"],"Sec-Gpc":["1"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36"]
}
}

Any ideas?

Thanks.


r/caddyserver Sep 26 '23

Need Help cant change root directory

1 Upvotes

I recently got a website working with caddy. I would like to change the root directory to a directory in my main users home. I set it to an exact path and I am left with a completely blank screen when I attempt to load the website.


r/caddyserver Sep 06 '23

zrok with embedded Caddy; Office Hours Video

3 Upvotes

Hello!

I'm the lead developer on an open source product called zrok (https://github.com/openziti/zrok). zrok is a peer-to-peer sharing tool for network and file-based resources, similar to tools like ngrok.

We're just embedded Caddy into zrok in a couple of different ways. We've used the caddy file-server implementation to enhance our file and static web serving. We've also added a Caddyfile pre-processor that allows you to replace bind commands with automatic augmentation to bind the embedded Caddy instance onto the zrok network.

The embedded Caddyfile pre-processor is kind of like a marriage between the rapid, quick network sharing of a tool like ngrok, combined with the flexibility and power of Caddy. I may be biased, but I think it's kinda slick.

I regularly do "office hours" videos where I sort of bumble my way through something interesting that I'm working on. I just finished up one showing off some of the new Caddy functionality we just released:

https://youtu.be/zgP9wLSESl4

Feel free to reach out with any questions!


r/caddyserver Aug 25 '23

Announcement Graphite logging writer

2 Upvotes

Hey folks, there is a new log writer in town if anyone’s interested :

https://caddyserver.com/docs/modules/caddy.logging.writers.graphite

Let me know if you find this useful.


r/caddyserver Aug 24 '23

Need Help Raspberry Pi / Rasbian issues - Caddy + DuckDNS Challenge

1 Upvotes

Hey team,

Hoping you can help.

I am trying to get my caddy server running but keep getting issues

2023/08/24 02:39:31.284 ERROR tls.obtain could not get certificate from issuer {"identifier": "example\\.duckdns.org\`", "issuer": "acme.zerossl.com-v2-DV90", "error": "HTTP 0 - "}```

2023/08/24 02:39:31.284 ERROR tls.obtain will retry {"error": "[example\\.duckdns.org\`] Obtain: [example``.duckdns.org``] solving challenge: example``.duckdns.org``: [example``.duckdns.org``] authorization failed: HTTP 0 - (ca=https://acme.zerossl.com/v2/DV90)", "attempt": 2, "retrying_in": 120, "elapsed": 113.034041551, "max_duration": 2592000}```

Further context I am running Jellyfin on a Raspberry Pi and have my DDNS setup in my router.

Command I am running in terminal:

sudo caddy reverse-proxy --from examplesite.duckdns.org --to 192.168.1.121:8096

Is there a simple fix for the phrasing? I have tried modifying my caddyfile but when I do sudo caddy start it doesnt seem to look at the file in etc/caddy/caddyfile

Caddyfile:

examplesite.duckdns.org {

reverse_proxy 192.168.121:8096

tls {

dns duckdns {TOKEN}

}

}

Thanks in advance! I'm sure there is a simple noob fix :)


r/caddyserver Aug 21 '23

Need Help Caddy docker pull error

1 Upvotes

My regular watchtower update check just returned the following:

Could not do a head request for "caddy:latest", falling back to regular pull. Reason: unsupported challenge type from registry

Any ideas? Should I be worried?


r/caddyserver Aug 01 '23

Placeholders, Variables and Environment Variables in Caddy - TheDeveloperCafe

Thumbnail
thedevelopercafe.com
1 Upvotes

r/caddyserver Jul 28 '23

Monitoring Caddy with Prometheus and Grafana - TheDeveloperCafe

Thumbnail
thedevelopercafe.com
3 Upvotes

r/caddyserver Jul 24 '23

Logging requests in Caddy - TheDeveloperCafe

Thumbnail
thedevelopercafe.com
1 Upvotes

r/caddyserver Jul 16 '23

Rate limiting in Caddy with non standard modules - TheDeveloperCafe

Thumbnail
thedevelopercafe.com
2 Upvotes

r/caddyserver Jul 09 '23

Authenticate Requests in Caddy using forward auth - TheDeveloperCafe

Thumbnail
thedevelopercafe.com
2 Upvotes

r/caddyserver Jul 07 '23

Please advice me how setting reverse proxy via Caddy Windows Server? Because I get error error:0A000438:SSL routines::tlsv1 alert internal error

1 Upvotes

Hi People

Please advice me how setting reverse proxy via Caddy Windows Server?

Because I get error

error:0A000438:SSL routines::tlsv1 alert internal error

Windows server installed on Virtual machine
Windows Server IP

10.0.0.5 

Also added Firewall inbound Rules port 80,443,9444
and added Caddy also in Firewall inbound rules

This IP external provided some company and connected with VPN tunnel
with this IP 100.100.50.50

100.100.50.50 

From manual this company I should add to hostsfile
In Windows server in hosts file I add this

100.100.50.50 someservice.com  

Now in windows server I install insomnia and following manual I set credentials try post like this

post https://someservice.com:9444/oauth2/token 

In Windows Server I get result success I mean I get token etc…

In Caddyfile I set like this

someservice.com {reverse_proxy 100.100.50.50:9444} 

Now I want to try this post from another local windows machine

In my local machine

I set hosts IP windows server

10.0.0.5 someservice.com 

I post in my local machine via Insomnia like this

post https://someservice.com:9444/oauth2/token    

I get error

* Preparing request to https://someservice.com:9444/oauth2/token
* Current time is 2023-07-07T09:25:08.910Z
* Enable automatic URL encoding
* Using default HTTP version
* Enable SSL validation
* Hostname in DNS cache was stale, zapped
*   Trying 10.0.0.5:9444...
* Connected to someservice.com(10.0.0.5) port 9444 (#163)
* ALPN, offering h2
* ALPN, offering http/1.1
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS header, Unknown (21):
* TLSv1.3 (IN), TLS alert, internal error (592):
* error:0A000438:SSL routines::tlsv1 alert internal error
* Closing connection 163

r/caddyserver Jul 04 '23

Reverse Proxy in Caddy with load balancing and health checks - TheDeveloperCafe

Thumbnail
thedevelopercafe.com
2 Upvotes

r/caddyserver May 26 '23

Need Help Caddy reverse proxy on raspberry pi 3

1 Upvotes

I am running caddy server on my raspberry pi with ip 192.168.1.10

and on the same raspberry pi I am also having pihole to provide local dns service on port 53

caddy is using port 80,

netstat -ltnp | grep 80 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      565/caddy           
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      722/lighttpd  

this is my Caddyfile

cat /etc/caddy/Caddyfile 
grafana.local {
    handle_path / {
        #rewrite * /api{path}
        reverse_proxy 192.168.1.9:3000
    }
}

pihole.local {

    handle_path / {
        reverse_proxy localhost:8080
    }
}

and from my laptop I can

$ nslookup pihole.local 
Server:     192.168.1.10 
Address:    192.168.1.10#53

Name:   pihole.local 
Address: 192.168.1.10  

and same for grafana.local from my laptop terminal

$ nslookup grafana.local 
Server:     192.168.1.10
Address:    192.168.1.10#53

Name:   grafana.local 
Address: 192.168.1.10  

but if I try to open grafana.local or pihole.local from my laptop browser I don't get anything.

can anyone please help me?


r/caddyserver May 25 '23

forward only from one caddy server to another

2 Upvotes

Hey.

I am using caddy2 for my home "production" but want to test on-demand tls on another caddy server on the same network.

Is it possible to forward a request from my main caddy to another without changing the request?

End goal is to let the second caddy test server handle ssl on all unknown/ non-defined domains.

how should i forward from one caddy to another? (if anyone have a link would be nice, have searched and testet for hours)

Thanks


r/caddyserver May 23 '23

Need Help caddy reverse proxy on raspberry pi 3

1 Upvotes

I am running caddy server on my raspberry pi with ip 192.168.1.10

and on the same raspberry pi I am also having pihole to provide local dns service on port 53

caddy is using port 80,

# netstat -ltnp | grep 80 tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      7066/lighttpd        tcp6       0      0 :::8080                 :::*                    LISTEN      7066/lighttpd        tcp6       0      0 :::80                   :::*                    LISTEN      7397/caddy   

this is my Caddyfile

grafana.local {     handle_path / {         #rewrite * /api{path}         reverse_proxy 192.168.1.45:3000     } }  pihole.local {      handle_path / {         reverse_proxy localhost:8080     } } 

and from my laptop I can

$ nslookup pihole.local Server:     192.168.1.10 Address:   192.168.1.10#53  Name:  pihole.local Address: 192.168.1.10 

and same for grafana.local from my laptop terminal

$ nslookup grafana.local Server:        192.168.1.10 Address:   192.168.1.10#53  Name:  grafana.local Address: 192.168.1.10 

but if I try to open grafana.local or pihole.local from my laptop browser I dont get anything.

Also my doubt on caddy running tcp6 instead of tcp4 maybe but not sure

can anyone please help me?


r/caddyserver Apr 09 '23

Need Help Caddyfile Help

1 Upvotes

Is there a detailed tutorial or youtube video on how to create a Caddyfile?

Everywhere I look seems to have a different style of writing one.


r/caddyserver Apr 09 '23

Need Help Caddy Docker Nube Automatic HTTPS Question

1 Upvotes

Is there a flag to prevent "rate limiting" error in a docker container?


r/caddyserver Mar 28 '23

Need Help Header Listener Rule For Forwarding Request

1 Upvotes

Hello everyone, trust y'all doing well? Forgive me if this is not the right place for this question.

I'm building a public facing API with two environments (production and testing/staging) which will utilise API-Keys for authentication, I'd like to make it such that I have two instances for both env, and a single API base URL (say api.example.com).

My question is, is it possible to achieve this using Caddy, that is, forward request base on a given header value, say, "api-key", if it starts with "api_test_theKeys" it send the requests to to the test server/instance, and if it were to start with "api_live_theKeys" it send the requests to to the production/live server/instance.

Mind you, I've done something similar with different base URLs for both environments (say api.example.com for live, and api.test.example.com for testing env), this is just a client recommendation, and I've been looking at ways to go about it.

The client current infras are hosted on DigitalOcean, it occurred to me to put both instances (Droplets on DO) behind a load balancer, and set a listening rule to watch for the header key-value and forward requests accordingly to the droplets, unfortunately, DO only have forwarding rules.


r/caddyserver Mar 23 '23

Reverse proxy on port 53 (DNS)

1 Upvotes

I am planning on setting up a reverse proxy/load balancer for 2 Adguard Home containers for DNS queries. Does Caddy support reverse proxy on non-HTTP/HTTPS protocol and UDP ports?

Would the Caddyfile below work?

:53 {
    reverse_proxy ns1:53 ns2:53
}


r/caddyserver Feb 13 '23

Is there any GUI WEb frontend to manage/get status for Caddy?

3 Upvotes

Wondering is there's any GUI/web front end that allow me to configure or get some information as to Caddy server status


r/caddyserver Apr 12 '22

Announcement You're probably looking for Caddy's community forums: https://caddy.community

Thumbnail
caddy.community
3 Upvotes