"Invalid URI" crash after first HTTP request

I’ve had a working Duplicati setup in a TrueNAS jail for a while, but recently I made some changes and it’s completely broken, even if I change everything back (I switched from to ::1 as the listen address). For some context, I created my own jail rather than using the plugin, I reverse proxy to the webservice using Nginx in the jail, and I have two Google Drive and one Azure Storage backup destinations. The folders and files are passed in via mounts, and the permissions are all set correctly. The command-line which starts Duplicati is the following:

/usr/local/bin/mono /usr/local/share/duplicati/Duplicati.Server.exe --webservice-port=8200 --webservice-interface=::1 --webservice-password='[redacted]' -d /config/

And nginx contains a proxy_pass block:

location / {
    proxy_pass http://[::1]:8200;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $http_add_x_forwarded_for;
    proxy_set_header Connection "Keep-Alive";
    proxy_set_header Proxy-Connection "Keep-Alive";

However, the server doesn’t start properly. When I run the command directly or use the service, it starts with no output, then if I hit it with a request, it just crashes with the following stacktrace:

[ERROR] FATAL UNHANDLED EXCEPTION: System.UriFormatException: Invalid URI: The hostname could not be parsed.
  at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x0007b] in <b3922b7d60404fa9ae645f1fb97f5b6b>:0 
  at System.Uri..ctor (System.String uriString) [0x00014] in <b3922b7d60404fa9ae645f1fb97f5b6b>:0 
  at HttpServer.HttpClientContext.OnRequestLine (System.Object sender, HttpServer.Parser.RequestLineEventArgs e) [0x00095] in <bed89f1655ee48029f6d6812f54c58ad>:0 
  at (wrapper delegate-invoke) System.EventHandler`1[HttpServer.Parser.RequestLineEventArgs].invoke_void_object_TEventArgs(object,HttpServer.Parser.RequestLineEventArgs)
  at HttpServer.Parser.HttpRequestParser.OnFirstLine (System.String value) [0x00172] in <bed89f1655ee48029f6d6812f54c58ad>:0 
  at HttpServer.Parser.HttpRequestParser.Parse (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x0010f] in <bed89f1655ee48029f6d6812f54c58ad>:0 
  at HttpServer.HttpClientContext.OnReceive (System.IAsyncResult ar) [0x00059] in <bed89f1655ee48029f6d6812f54c58ad>:0 
  at System.Net.Sockets.SocketAsyncResult+<>c.<Complete>b__27_0 (System.Object state) [0x0000b] in <b3922b7d60404fa9ae645f1fb97f5b6b>:0 
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00008] in <0e06830de9a44394a7e366951eabca52>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <0e06830de9a44394a7e366951eabca52>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <0e06830de9a44394a7e366951eabca52>:0

(I’ve tried using log-file and log-level, but I can’t get that to work, I get a Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null. when I add the --log-file argument)

Because it doesn’t say, I’m not sure which hostname is the issue, whether that’s what’s being passed by the proxy (I’ve confirmed via tcpdump that the Host header is normal) or if it’s a destination URL that for some reason is not good anymore. I also am not familiar enough with the CommandLine.exe file or any other one, or the webservice options to be able to debug this further, despite my best attempts.

Any advice for further troubleshooting steps or a solution?

Welcome to the forum @dhellstern

I don’t use TrueNAS or Nginx, so maybe somebody else can help, but I’ll start on the preliminaries.

Web interface not accessible via IPv6 #4177 suggests it can’t get ::1. What does netstat think?

The web server part of Duplicati is a separate project (it lives here) so log integration is likely poor.
I usually keep a log running at profiling level, but don’t see the web server part giving me things.

You are probably ahead of me on HTTP, but in my usage I tend to use localhost:8200, and have:

Host: localhost:8200

Is it complaining when you try to use ::1 for a host? What does “normal” look like in your tcpdump?
Since web server doesn’t do IPv6, possibly there’s an issue with IPv6. I’m not familiar with the code.


My guess from quick source search is it’s crashing on last code line below because IPv6 is different.
I’m still not sure how you got connected to the web server over IPv6, but if you did, it might get upset.
Format for Literal IPv6 Addresses in URL’s fills in a gap of an earlier spec that might also apply here:

Looks like you’re right, Duplicati does not support IPv6, which is honestly disappointing in this day and age. Changing everything to worked, and it turns out I messed up my troubleshooting when I tried that before, since I was running Duplicati as a different user to test manually running it rather than via a service, which meant it couldn’t load the configuration that allowed hostnames other than localhost.

1 Like

Switch the webserver to a more maintained version #1501 is a broader open issue. Fixing it might get IPv6.
As usual, the amount of fixing that can be done depends on the number of volunteers, which has been low.
Interestingly, the one I just referenced had an update 2 days ago from someone who possibly could work it.

If I’m still working on this project by the time #3124 gets merged, I would probably look at making a PR for kestrel.

Unfortunately, looks like the .NET 5 migration started in 2018, and won’t be done for a while, blocking Kestrel adoption. It’s completely understandable, upgrading .NET versions is not something I envy having to do.