I have HAProxy running on my WAN. One of the services it serves is my self-hosted nextcloud server, located on my LAN. From my LAN, I can go to cloud.mydomain.com, which resolves to my WAN IP and everything is fine. From the internet, I can do the same.
However, in the System->Configuration->Backup, when I put https://cloud.mydomain.com (https://cloud.mydomain.com) in the URL field, the backup test fails. In the logs I see that it's not resolving the domain name:
{"url":"https:\/\/cloud.mydomain.com\/remote.php\/dav\/files\/steve\/","content_type":null,"http_code":0,"header_size":0,"request_size":0,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":60.005564,"namelookup_time":0.004236,"connect_time":0,"pretransfer_time":0,"size_upload":0,"size_download":0,"speed_download":0,"speed_upload":0,"download_content_length":-1,"upload_content_length":-1,"starttransfer_time":0,"redirect_time":0,"redirect_url":"","primary_ip":"","certinfo":[],"primary_port":0,"local_ip":"","local_port":0,"http_version":0,"protocol":0,"ssl_verifyresult":0,"scheme":"","appconnect_time_us":0,"connect_time_us":0,"namelookup_time_us":4236,"pretransfer_time_us":0,"redirect_time_us":0,"starttransfer_time_us":0,"total_time_us":60005564}
What I've checked:
- In Interfaces->Diagnostics->DNS Lookup, get resolution on cloud.mydomian.com
- From command line: ping cloud.mydomain.com pings my WAN interface
- From command line: dig cloud.mydomain.com returns WAN IP
- From command line: host cloud.mydomian.com returns WAN IP
look at the connection duration:
"total_time"=>60.005564,
This is a good sign for some kind of a timeout. Maybe it cannot reach the server. have you checked curl on cli?
My setup is like so:
I have HAProxy bound to 127.0.0.1, and then I do a port-forward from the WAN port 443 to 127.0.0.1. I did this because I have an IP issued over DHCP from my ISP and I only wanted HAProxy listening on the WAN interface.
If I change HAPoxy to bind to 0.0.0.0:443, then it works. I guess what I don't understand is in my original way, I can get to NextCloud from the Internet and every machine on the LAN, but it will not work from the router itself. Any clues?