Accessing an IP camera through caddy

1. Output of caddy version:


2. How I run Caddy: {
reverse_proxy rtmp://

a. System environment:

Ubuntu server 22.04, systemd

b. Command:

sudo systemctl reload caddy

c. Service/unit/compose file: {
        reverse_proxy rtmp://

d. My complete Caddy config: {
        reverse_proxy rtmp://

3. The problem I’m having:

I am trying to access a rtmp stream of an internal IP camera, from the internet using a web browser. The config above is what I have tried, but no luck so far.

4. Error messages and/or full log output:


5. What I already tried:

I have tried the above config using HTTP, RTSP and RTMP streams

6. Links to relevant resources:

Caddy’s standard distribution is an HTTP server and proxy. It can’t proxy RTMP because that’s not HTTP.

You could use GitHub - mholt/caddy-l4: Layer 4 (TCP/UDP) app for Caddy plugin which would let you proxy raw TCP (including RTMP).

1 Like

my camera can also output the stream over HTTP in this format:

anything I can do with this?

You could possibly try this: {
	rewrite * /flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=123456

I tried it. Caddy reloads with no errors, but page does not load.


Not much I can do with that information (or lack thereof).

Ye, please provide more information.

Have a look at your web browsers’ network tab in the dev tools.
You could also compare the network tab when you open vs

And enable http access logs in Caddy, like so: {
	rewrite * /flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=123456

To read those just enabled logs, use journalctl -u caddy --no-pager | less +G, as mentioned in Keep Caddy Running — Caddy Documentation :innocent:

1 Like

Yes, I understand. But being a newbie I could only help you with further info if you tell me where and how to look.

The http://192… works well in the web browser. Only through does not work.
PS is not the real domain I use, but it should not have an effect on my issue. I use other links in my caddyfile (eg, and they all work ok.

I am not sure where to paste the log (output of journalctl -u caddy --no-pager | less +G) because it’s huge, but the part since the last caddy reload can be seen here.

I figured something out…
@IndeedNotJames 's reply was of great help.

When I access the internal IP stream address through a browser (eg. “…”), the stream worked fine.
When I tried to access the stream through the domain name (eg. “…”) the page was not loadig, BUT ONLY FROM MY INTERNAL NETWORK. If I use a VPN or access this domain from anywhere outside of my network, everything worked as expected.

Anyways, thank you @francislavoie and @IndeedNotJames for putting up with someone with my embarrassing level of IT skills.

Ah that makes sense. That’s typically because your router doesn’t support NAT hairpinning, i.e. it doesn’t know how to route connections to your WAN IP back into your local network. See Network address translation - Wikipedia

One way to solve that is to use a DNS server in your local network to make that domain resolve to your LAN IP instead for devices inside your network. Or use a different domain which you make resolve to your LAN IP, if you don’t absolutely need it to be the same domain (for cookies to be remembered by the browser, or whatever).


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