[akka-http] IllegalUriException

132 views
Skip to first unread message

Frederic Masion

unread,
Sep 28, 2015, 2:55:08 PM9/28/15
to Akka User List
Hi everybody,

I have a strange IllegalUriException with akka-http :

My app is quite simple : a logging proxy

I have configured my network to use this proxy for all http requests.

what the proxy does : 

val route: Route =
logging {
{
forward
}
}

Http().bindAndHandle (route, "localhost", 8181)

logging directive only extracts method, path... and logs it

to forward Route is defined here :

trait Forwader {this : ProxyDirective =>

def forward : StandardRoute =
StandardRoute { (context: RequestContext) =>
val future = Http().singleRequest(context.request)
future.fast.transformWith {
case Success(res) ⇒ context.complete(res)
case Failure(error) ⇒ context.complete(StatusCodes.InternalServerError, s"An error occurred: ${error.getMessage}")
}
}

}

Everything is very basic and works fine with default port BUT I have plenty of ERROR logs like this one :

[ERROR] [09/28/2015 20:38:26.583] [Proxy-akka.actor.default-dispatcher-283] [ActorSystem(Proxy)] Internal server error, sending 500 response
akka.http.scaladsl.model.IllegalUriException: 'Host' header value of request to `notify1.dropbox.com:443` doesn't match request target authority: Host header: Some(Host: notify1.dropbox.com)

[ERROR] [09/28/2015 20:46:21.163] [Proxy-akka.actor.default-dispatcher-386] [ActorSystem(Proxy)] Internal server error, sending 500 response
akka.http.scaladsl.model.IllegalUriException: 'Host' header value of request to `openoox.com:8080` doesn't match request target authority: Host header: Some(Host: openoox.com:8080)
request target authority:

Has soon as the HOST header of the response contains a port with the http protocol I have a IllegalUriException

Did I missed something ?

Fred

Akka Team

unread,
Oct 2, 2015, 6:17:48 AM10/2/15
to Akka User List
HI Fred,

I am not sure, but does the Host header allow ports to be defined? I am not sure what the RFC says on this matter, but Akka Http (and Spray) tends to follow the rules by-the-book most of the time.

-Endre

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam

André

unread,
Oct 2, 2015, 9:21:59 AM10/2/15
to Akka User List
Hi Frederic,

ports in Host headers should be fine (see http://tools.ietf.org/html/rfc7230#section-5.4) and be supported by akka-http. Just make shure that both host and port of the request URI are the same as in the Host header.

The port checking seems to currently be missing. Therefore I filed https://github.com/akka/akka/issues/18632.

Cheers
André

Akka Team

unread,
Oct 2, 2015, 9:25:34 AM10/2/15
to Akka User List
Hi André,

Thanks for chiming in!

-Endre
Reply all
Reply to author
Forward
0 new messages