8000 HTTP Router module to discard proxy side-effects by ashald · Pull Request #553 · linkerd/linkerd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

HTTP Router module to discard proxy side-effects #553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2016

Conversation

ashald
Copy link
Member
@ashald ashald commented Jul 22, 2016
  • Strip host from URI
  • Drop Proxy-* requests

Request considered being proxied if its URI is absolute

@ashald
Copy link
Member Author
ashald commented Jul 22, 2016

@olix0r, another PR to your attention - as we agreed yesterday :)

def apply(req: Request, svc: Service[Request, Response]) = {
if (!req.uri.startsWith("/")) { // Proxied request
// split URI like http://acme.co/foo/bar?x=1 into host 'acme.co' and uri 'foo/bar?x=1'
val Array(_, _, host, uri) = req.uri.split("/", 4)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will throw an exception if there aren't 4 elements returned. we should be more tolerant of unexpected input:

req.uri.split("/", 4) match {
  case Array(...) =>
  case _ => // doesn't match ...
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If at all possible i'd prefer to use a real url parser. URLs come in some unexpected shapes and sizes. Does java.net have something that does this job?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense. At first I thought about keeping it simple but I was still in doubts. I'll dig API, thanks for an advice.

@olix0r
Copy link
Member
olix0r commented Jul 29, 2016

All in all this looks good! A few small comments...

@@ -32,6 +32,7 @@ object Http extends Router[Request, Response] with FinagleServer[Request, Respon
val client: StackClient[Request, Response] = FinagleHttp.client
.transformed(StackRouter.Client.mkStack(_))
.transformed(_.replace(http.TracingFilter.role, http.TracingFilter.module))
.transformed(_.insertBefore(http.TracingFilter.role, DiscardProxySideEffects.module))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, I think that this needs to be installed on the serverside and not the client-side.

We want this rewriting to happen before we apply an Identifier to the request (which happens above the client).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I failed and put it in wrong place although you initially told me to put it onto the server side. %) Will fix, thanks.

@ashald ashald force-pushed the feature/fix-proxied-requests branch from 6ff62dd to 95633d8 Compare August 2, 2016 17:02
@ashald
Copy link
Member Author
ashald commented Aug 2, 2016

@olix0r pushed an updated - please take another look

import com.twitter.finagle.client.StackClient
import com.twitter.finagle.http.{Request, Response, TlsFilter}
import com.twitter.finagle.param.ProtocolLibrary
import com.twitter.finagle.server.StackServer
import com.twitter.finagle.{Http => FinagleHttp, Server => FinagleServer, http => fhttp, _}
import io.buoyant.router.Http.param.HttpIdentifier
import io.buoyant.router.http.{ForwardedFilter, MethodAndHostIdentifier, StripConnectionHeader}
import java.net.SocketAddress
import io.buoyant.router.http.{DiscardProxySideEffects, ForwardedFilter, MethodAndHostIdentifier, StripConnectionHeader}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super minor: can yiou please sort imports without breaking out sections.

From Effective Scala

Sort import lines alphabetically
This makes it easy to examine visually, and is simple to automate.

IntelliJ, etc have settings to configure this.

@olix0r
Copy link
Member
olix0r commented Aug 8, 2016

Sorry, just a few more nits. Once we fix that test, I think this is good to go.

@ashald ashald force-pushed the feature/fix-proxied-requests branch from 95633d8 to 9d738f0 Compare August 14, 2016 19:47
* Strip authority from the URI
* Restore Host header value (HTTP/1.1)
* Drop Proxy-* headers

Request considered being proxied if its URI is absolute
@ashald ashald force-pushed the feature/fix-proxied-requests branch from 9d738f0 to d69f4a7 Compare August 14, 2016 20:07
@olix0r
Copy link
Member
olix0r commented Aug 16, 2016

lgtm!

Approved with PullApprove

@adleong adleong merged commit 86d6d20 into linkerd:master Aug 16, 2016
ashald added a commit to ashald/linkerd that referenced this pull request Aug 17, 2016
* Strip authority from the URI
* Restore Host header value (HTTP/1.1)
* Drop Proxy-* headers

Request considered being proxied if its URI is absolute
ashald added a commit to ashald/linkerd that referenced this pull request Aug 17, 2016
* Strip authority from the URI
* Restore Host header value (HTTP/1.1)
* Drop Proxy-* headers

Request considered being proxied if its URI is absolute
@ashald ashald deleted the feature/fix-proxied-requests branch August 22, 2016 16:21
Tim-Brooks pushed a commit to Tim-Brooks/linkerd that referenced this pull request Dec 20, 2018
Applies timeout of 5s to check request contexts. This overrides
30s timeout applied at client transport level, and stops the
conduit check command from taking > 90s to complete.

Fixes linkerd#553

Signed-off-by: Andy Hume <andyhume@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0