Reverse proxy not working (partially)

I’m setting up caddy as a reverse proxy in front of nginx to serve a wordpress website. Caddy and nginx is located on different server.

The website is working. However, when I try to enter an url like http://example.com/wp-admin (which is exist folder), instead of going to the wp-admin page (forwarding to wp-login.php), caddy display an error “refused to connect” with address showing http://example.com:port/wp-admin/.
Same problem if trying to enter other exist folder like wp-content…

My Caddyfile is as following:

.example.com {
    tls me@example.com {
        dns cloudflare
        key_type rsa4096
    }
}

example.com:80 {
    errors /var/log/caddy/errors.log
    gzip { level 9 }
    proxy / xxx.xxx.xxx.xxx:port {
        websocket
        transparent
    }
}

Is there anything I did wrong here? Sorry I’m very new to this reverse proxy. Also, why did the error page showing the forwarding port here? Would this affect the security? How can I stop caddy to showing the forwarding port?

Hi @ltv, welcome to the Caddy community.

Can you post the exact error you’re getting, the exact URL you were trying to navigate to, and the exact URL you end up with (please copy+paste all three).

You could also post the output of running curl -IL example.com:80 from any computer, and possibly the output of curl -ILH "Host:example.com" xxx.xxx.xxx.xxx:port/wp-admin/ run from the Caddy host machine.

I also note you have errors configured. What appears in this log when you get this error?