toxikat
Dabbler
- Joined
- Nov 3, 2022
- Messages
- 27
Hi all, here with a basic networking issue I'm struggling with.
Basic description: I cannot access my nextcloud on my local network nor remotely. A week ago, everything was working fine, so I'm a bit surprised that there were some issues.
Setup:
Some observations:
1. My server had nearly exactly 1 year of uptime when this became inaccessible. I'm pretty sure this was just a coincidence.
2. My ISP reset my IPV4. I have since updated my cloudflare's example.com to point to the new ipv4.
3. At time of failure, both Jellyfin and Nextcloud were unaccessble, but i was able to get jellyfin up and running after the ipv4 update in cloudflare.
I'm willing to get rid of the Nextcloud's caddyfile if it makes things simpler. I originally set the box up as only having nextcloud, and later on adding other things. If it would make things simpler, would definitely be open to condensing things somehow to only use Caddy jail's caddyfile.
Another note: In my NC's Caddyfile, I have a port declared, ":9010". When I hit this port via my pc locally with `curl 192.168.1.70:9010`, it returns 200 fine. This might be a weak signal but I thought I'd point this out.
Currently, when I try to access `my.example.com`, i get a 502 bad gateway. I have traced the logs as follows:
One thing I want to call out is that in nextcloud's jail's Caddy log (posted down there), there is the line `dialing backend: dial tcp 127.0.0.1:9000: connect: connection refused`. I'm not sure what this means and searching didn't come up with an obvious cause. I'm worried that Nextcloud somehow isn't running, but I'm actually not sure how to check that since I can't access the NC admin console locally (occ runs fine though).
1. In the Caddy jail, I see this caddy log:
Then, in my Nextcloud jail, I see
# Caddy jail's Caddyfile:
/etc/hosts
# Nextcloud jail's Caddyfile:
nextcloud's config.php
Basic description: I cannot access my nextcloud on my local network nor remotely. A week ago, everything was working fine, so I'm a bit surprised that there were some issues.
Setup:
- TrueNAS core 13.0-U2
- I have a jail just for Caddy @ 192.168.1.199
- Here, I run a "main" Caddy. The Caddyfile is listed at the bottom.
- Nextcloud lives in a jail @ 192.168.1.70 (subdomain is "my")
- Here, I run a "sub" Caddy. also listed at the bottom.
- I have also pasted parts of my nextcloud's config.php down
- I have a jail for Jellyfin @ 192.168.1.101 (subdomain is "watch").
- This works externally and locally, which tells me that my port forwarding situation should be ok.
- I do not run a caddy here, the main caddy directly reverse proxies jellyfin's ip/port
- Domain registered on Cloudflare, example.com, all proxied
- Here I have an A record for example.com
- CNAME records for my subdomains.
- SSL/TLS on "Full (Strict)"
- If any other info is needed, let me know.
Some observations:
1. My server had nearly exactly 1 year of uptime when this became inaccessible. I'm pretty sure this was just a coincidence.
2. My ISP reset my IPV4. I have since updated my cloudflare's example.com to point to the new ipv4.
3. At time of failure, both Jellyfin and Nextcloud were unaccessble, but i was able to get jellyfin up and running after the ipv4 update in cloudflare.
I'm willing to get rid of the Nextcloud's caddyfile if it makes things simpler. I originally set the box up as only having nextcloud, and later on adding other things. If it would make things simpler, would definitely be open to condensing things somehow to only use Caddy jail's caddyfile.
Another note: In my NC's Caddyfile, I have a port declared, ":9010". When I hit this port via my pc locally with `curl 192.168.1.70:9010`, it returns 200 fine. This might be a weak signal but I thought I'd point this out.
Currently, when I try to access `my.example.com`, i get a 502 bad gateway. I have traced the logs as follows:
One thing I want to call out is that in nextcloud's jail's Caddy log (posted down there), there is the line `dialing backend: dial tcp 127.0.0.1:9000: connect: connection refused`. I'm not sure what this means and searching didn't come up with an obvious cause. I'm worried that Nextcloud somehow isn't running, but I'm actually not sure how to check that since I can't access the NC admin console locally (occ runs fine though).
1. In the Caddy jail, I see this caddy log:
Code:
2024/04/01 00: 40: 46.251 error http.log.access.log0 handled request { "request": { "remote_ip": "1<some ip>3", "remote_port": "13478", "proto": "HTTP/2.0", "method": "GET", "host": "my.example.com", "uri": "/", "headers": { "Cf-Ray": [ "86b-XXX" ], "X-Forwarded-Proto": [ "https" ], "User-Agent": [ "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0" ], "Accept": [ "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8" ], "Sec-Fetch-Dest": [ "document" ], "Cf-Connecting-Ip": [ "my ipv4" ], "Sec-Fetch-Site": [ "none" ], "Sec-Fetch-User": [ "?1" ], "Accept-Encoding": [ "gzip, br" ], "Accept-Language": [ "en-US,en;q=0.5" ], "Upgrade-Insecure-Requests": [ "1" ], "Sec-Fetch-Mode": [ "navigate" ], "Cdn-Loop": [ "cloudflare" ], "Cf-Ipcountry": [ "CA" ], "X-Forwarded-For": [ "my ipv4" ], "Cf-Visitor": [ "{\"scheme\":\"https\"}" ], "Priority": [ "u=1" ], "Cookie": [] }, "tls": { "resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "server_name": "my.example.com" } }, "user_id": "", "duration": 0.002616458, "size": 0, "status": 502, "resp_headers": { "Strict-Transport-Security": [ "max-age=31536000;" ], "Content-Length": [ "0" ], "Date": [ "Mon, 01 Apr 2024 00:40:46 GMT" ], "Server": [ "Caddy", "Caddy" ], "Alt-Svc": [ "h3=\":443\"; ma=2592000" ] } }
Then, in my Nextcloud jail, I see
Code:
2024/04/01 00: 44: 02.489 ERROR http.log.error.log0 dialing backend: dial tcp 127.0.0.1: 9000: connect: connection refused { "request": { "remote_ip": "192.168.1.199 (caddy jail ip)", "remote_port": "45585", "proto": "HTTP/2.0", "method": "GET", "host": "my.example.com", "uri": "/", "headers": { "Accept": [ "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8" ], "Accept-Language": [ "en-US,en;q=0.5" ], "Cookie": [], "Cf-Ipcountry": [ "CA" ], "Sec-Fetch-Site": [ "none" ], "X-Forwarded-For": [ "some public ipv4 i dont know, probs cloudflares" ], "Cdn-Loop": [ "cloudflare" ], "Priority": [ "u=1" ], "Accept-Encoding": [ "gzip, br" ], "Sec-Fetch-Dest": [ "document" ], "Cf-Connecting-Ip": [ "2xxx7" ], "Sec-Fetch-User": [ "?1" ], "Cf-Ray": [ "86xxd9c-xxx" ], "X-Forwarded-Host": [ "my.example.com" ], "User-Agent": [ "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0" ], "X-Forwarded-Proto": [ "https" ], "Sec-Fetch-Mode": [ "navigate" ], "Upgrade-Insecure-Requests": [ "1" ], "Cf-Visitor": [ "{\"scheme\":\"https\"}" ] }, "tls": { "resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "server_name": "my.example.com" } }, "duration": 0.000706038, "status": 502, "err_id": "qqu6epghb", "err_trace": "reverseproxy.statusError (reverseproxy.go:1272)" }
# Caddy jail's Caddyfile:
Code:
root@caddy:/usr/local/www # cat Caddyfile { email <my email> } :2020 { respond "sample text" } my.example.com { log { output file /var/log/caddy/nextcloud-access.log level DEBUG } reverse_proxy https://my.example.domain # nextcloud aliased via /etc/hosts } watch.example.com { reverse_proxy 192.168.1.101:8096 # jellyfin }
/etc/hosts
Code:
root@caddy:~ # cat /etc/hosts # $FreeBSD$ ... lots of comments # ::1 localhost localhost.my.domain 127.0.0.1 localhost localhost.my.domain caddy # ... whole bunch of comments # 192.168.1.199 caddy 192.168.1.70 my.example.com
# Nextcloud jail's Caddyfile:
Code:
{ # debug #acme_ca https://acme-staging-v02.api.letsencrypt.org/directory email <my email> default_sni my.example.com } :9010 { respond "nc" } my.example.com { root * /usr/local/www/nextcloud file_server log { output file /var/log/my.example.com.log } php_fastcgi 127.0.0.1:9000 { env front_controller_active true } tls { dns cloudflare <redacted key, not even sure if this is correct anymore tbh> } header { # enable HSTS Strict-Transport-Security max-age=31536000; } # client support (e.g. os x calendar / contacts) redir /.well-known/carddav /remote.php/dav 301 redir /.well-known/caldav /remote.php/dav 301 redir /.well-known/webfinger /index.php/.well-known/webfinger 301 redir /.well-known/nodeinfo /index.php/.well-known/nodeinfo 301 # .htaccess / data / config / ... shouldn't be accessible from outside @forbidden { path /.htaccess path /data/* path /config/* path /db_structure path /.xml path /README path /3rdparty/* path /lib/* path /templates/* path /occ path /console.php } respond @forbidden 404 }
nextcloud's config.php
Code:
nextcloud# cat nextcloud/config/config.php <?php $CONFIG = array ( 'passwordsalt' => 'xxx', 'secret' => '3gxxxsZ', 'trusted_domains' => array ( 0 => 'localhost', 1 => 'my.example.domain', 2 => '192.168.1.70', 3 => '191.168.1.199', ), 'datadirectory' => '/mnt/files', 'dbtype' => 'mysql', 'version' => '24.0.7.1', 'overwrite.cli.url' => 'https://my.example.domain/', 'dbname' => 'nextcloud', 'dbhost' => 'localhost:/tmp/mysql.sock', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'nextcloud', 'dbpassword' => 's8LBxxxx4IA==', 'installed' => true, 'instanceid' => 'oclxxx9y', 'logtimezone' => 'America/xx', 'default_phone_region' => 'US', 'log_type' => 'file', 'logfile' => '/var/log/nextcloud/nextcloud.log', 'loglevel' => '2', 'logrotate_size' => '104847600', 'memcache.local' => '\\OC\\Memcache\\APCu', 'redis' => array ( 'host' => '/var/run/redis/redis.sock', 'port' => 0, ), 'memcache.distributed' => '\\OC\\Memcache\\Redis', 'memcache.locking' => '\\OC\\Memcache\\Redis', 'overwritehost' => 'my.example.domain', 'overwriteprotocol' => 'https', 'htaccess.RewriteBase' => '/', 'maintenance' => false, 'theme' => '', 'preview_max_memory' => 4096, 'preview_max_filesize_image' => 256, 'enabledPreviewProviders' => array ( 0 => 'OC\\Preview\\Image', 1 => 'OC\\Preview\\HEIC', 2 => 'OC\\Preview\\TIFF', 3 => 'OC\\Preview\\Movie', 4 => 'OC\\Preview\\MKV', 5 => 'OC\\Preview\\MP4', 6 => 'OC\\Preview\\AVI', ), 'memories.ffmpeg_path' => '/usr/local/bin/ffmpeg', 'memories.ffprobe_path' => '/usr/local/bin/ffprobe', 'memories.transcoder' => '/usr/local/www/nextcloud/apps/memories/exiftool-bin/go-vod-amd64', 'memories.no_transcode' => false, 'memories.qsv' => false, 'memories.gis_type' => 1, );
Last edited: