Caddy Server Listening Port AIRVPN issue

I can’t seem to get the port forwarding through airvpn to work for caddy server. I know the server is functioning correctly because if I take the vpn down everything works. I’m using airvpn’s port forwarding, and I have used this correctly for plex, but I can’t seem to figure out how to change the listening port for caddy server (I think that’s the issue).

I’m forwarding port 2015 through air’s service and when it checks, it says that everything is working, but I still can’t access domain.duckdns.org/sonarr outside my home network.

Is there something I’m missing that I can put in the caddy file to change the listening port to the end port on air’s end? I believe it’s essentially working something like this: local port 2015 -----> airvpn port xxxxx basically, correct? So in a nutshell I need to tell caddy to listen to the final port that is at the end? That’s how I got plex to work outside my home network.

Hi @bobbarker,

After checking out AirVPN, it looks like what it does is hide your IP behind one of its own, updating DDNS to match your new IP, and forwards ports back to you - without translating them:

When you remotely forward a port, our servers will open that port (TCP, UDP or both, according to your selection) and will properly forward incoming packets to you on that port.

You provide Remote Port Forwarding, what is it? - AirVPN

So an open port 2015 on your AirVPN should connect to your device at home on port 2015.

As long as Caddy is listening on that port, it should respond to the request through AirVPN.

Thanks for the quick reply!

Unfortunately that doesn’t seem to be the case. Here is my caddy file:

domain.duckdns.org { I also tried domain.airvpn.org neither worked.
tls off
proxy /sonarr 192.168.1.253:8989 {
transparent
}

proxy /radarr 127.0.0.1:7878 {
transparent
}

proxy /headphones 192.168.1.253:8181 {
transparent
}

So as soon as I turn off AIRVPN it works perfectly. I’m not sure why the port isn’t getting forwarded through?

One thing I did notice about AIRVPN and forwarding ports is that it says this:

Mapped to public IP: xxx.75.223.xxx
Forwarded to: xx.4.7.xxxx

Obviously these addresses are different. I’m uncertain what is going on here. I have forwarded port 2015 through AIRVPN though and the system from AIRVPN claims that it is forwarded properly. I also forwarded the port through my router even though according to AIRVPN you don’t have to.

Any ideas?

You’re using the AirVPN client on your server, right?

If so, they’re correct - forwarding your modem ports is unnecessary. Your client connects out to their server, and they pass back connections that they receive on their public IP directly through that tunnel back to you, so you don’t need any ports open at all and you should never get connection requests on your WAN interface.

As for ideas… You said you can’t access /sonarr outside the network. Does that mean that domain.airvpn.org/sonarr works inside the network? And do Radarr and Headphones work inside/outside the network?

So a few days ago with that caddyfile I had everything working as soon as I turned off the VPN from inside or outside my network when I went to domain.duckdns.org/sonarr. Now even without the VPN on I can’t seem to get it to come up from inside or outside the network, I can only pull it up by going to the internal ip on my home network of 192.168.1.252:8989… I don’t believe that I changed anything and now I’m really at a loss. Before this the only problem I had was when AIRVPN was on, but now I can’t even get caddy to run properly with AIRVPN off.

When caddy starts it does say:
activating privacy features… done
http://domain.duckdns.org:2015

Does that look right?

Also yes, AIRVPN is on the same computer as sonarr / radarr, caddy server etc.

Looks good to me.

But it seems like things are getting a little complicated because it looks like you’ve got a CNAME to a reverse proxy to a reverse proxy and I’m not 100% sure where all your domains are pointed. We should try to reduce the complexity as much as possible to get things working, then add complexity step by step to get our desired result.

The first step is to make sure Caddy’s working right. Lets make Caddy more permissive with regards to host, then try it out locally. Change the label of your Caddyfile to this:

:2015 {
  [...]
}

Then, browse to Caddy locally at [hostname]:2015/sonarr, using the hostname/IP address of your Caddy server, and see if Sonarr pops up.

If that works, spin up AirVPN and try to access domain.airvpn.org:2015/sonarr.

If that works, try domain.duckdns.org:2015/sonarr.

Let me know where it breaks down, and what error you get.

Ok, so this is really weird but here it goes.

:2015 {
[…]
}
force quits caddy server.

If I take the VPN down and put
domain.duckdns.org
proxy /sonarr 192.168.1.253:8989

it works from inside and outside my network at domain.duckdns.org/sonarr

Ok great, right?

Now if I put domain.airvpn.org caddy server immediately shuts off and won’t stay running. The cmd window pops up says activating privacy features then immediately shuts down. I also tried running as administrator and got the same thing. I swapped out the two domains multiple times with the same exact effect. Caddy Server refuses to stay running with domain.airvpn.org

Weird, right?

There’s almost certainly an error being printed but Windows is closing the cmd window before you have a chance to read it. You’ll want to open cmd and then type caddy -log stdout to run it and you will get full information this way.

1 Like

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