Handle_errors doesnot seem to be working?

1. The problem I’m having:

I’m trying to use the example code from the docs to replicate the 404 behaviour. But cant seem to get it working.

2. Error messages and/or full log output:

curl : The remote server returned an error: (404) Not Found.
At line:1 char:1
+ curl https://www.indrajeethaldar.com/example.html
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebEx
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

3. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy:

installed it using the docs - the LTS version here Install — Caddy Documentation.

a. System environment:

Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy

b. Command:

Please use the preview pane to ensure it looks nice.

c. Service/unit/compose file:

curl https://www.indrajeethaldar.com/example.html 

The above html page does not exist

also started the caddy system with

sudo caddy start --config Caddyfile

d. My complete Caddy config:

indrajeethaldar.com {
        redir https://www.indrajeethaldar.com{uri}

www.indrajeethaldar.com {
        root * /home/indrajeet/portfolio

handle_errors {
        rewrite * /{err.status_code}
        reverse_proxy https://http.cat {
                header_up Host {upstream_hostport}
                replace_status {err.status_code}

5. Links to relevant resources:

Tried using this example handle_errors (Caddyfile directive) — Caddy Documentation

Directives must always be in a site block. You put handle_errors outside your site, so Caddy thinks you’re trying to configure handle_errors as one of your domain names.

Wait so where should I put the directives - the documentation dosent say anything about that

I think you will find this page helpful: :slight_smile:

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