How to disable upstream proxy based on request.url in mitmproxy - mitmproxy

Is it possible to disable upstream proxy in Mitmproxy for request based on request properties (for example URL)?

Related

Vertx reverse proxy redirect handling

I'm pretty new to Vertx, I'm building a reverse proxy on Quarkus.
I need to handle a redirect response from my Apache to my Quarkus reverse proxy, so that my Client doesn't get redirected directly to the Apache server (bypassing the proxy).
Resource is located in custom.url/myResource/index.php
My reverse proxy is running on localhost:8080
Basically what happens is:
Browser sends a GET request on localhost:8080/myResource, Quarkus is listening on 8080 so he receives the request, remaps the url tocustom.url/myResource and forwards to Apache.
Apache creates a redirect response, because a slash was missing at the end of the url, so he sends a 301 response with the Location header set to custom.url/myResource/ (with slash at the end) to the Quarkus reverse proxy.
Quarkus will forward the redirect response (301 custom.url/myResource/) to the Client, so he will make a GET call straight to custom.url/myResource/ bypassing the Reverse Proxy.
This behavior is not acceptable, since I can't allow the client to know the resource address of my backend service.
Code snippet
Route route = this.proxyRouter.route(method, path)
.handler(CorsHandler.create("*"))
.handler(LoggerHandler.create())
.handler(ctx ->{ //need to create an handler to handle this behaviour })
.handler(ProxyHandler.create(myProxy);
What i have to do is basically setting the Location header of the response to the correct path, including the slash.
I tried to get the request.absoluteURI() hostname, the response subdomain (with the slash) and merge them together.
request URI: localhost:8080/myResource -> localhost:8080 (1)
response Location: custom.url/myResource/ -> /myResource/ (2)
So i get the wanted Location header merging (1) and (2): localhost:8080/myResource/
Logically this works, but I don't know where and if I'm able to do this inside the handler, or if I need to do it some other way. I tried to implement this logic inside the handler, but I'm only able to get the request URI, there was no way to find the 301 response.
Need help plz.

Passing response to upstream proxy only in certain cases

I am trying to implement routing in this manner:
no
client --> mitmproxy --> (check if hostname is in list of accepted) --> upstream proxy response
|
| yes
|
intercept response, check, return to client
+ don't allow to propagate upstream
I'm trying to implement a dynamic filter which will override the upstream proxy in some cases, and not in other cases.
I have a workaround method which is to have two mitm proxies, one which filters requests and chooses which proxy to use (upstream proxy or filter proxy) and then the filter proxy which inspects the content.

The PhpStorm HTTP client supports PATCH or http verb change for http requests?

The http client from phpStorm supports change http verbs in requests?
More info about this client - https://www.jetbrains.com/help/phpstorm/http-client-in-product-code-editor.html#run_request . I read the HTTP Requests Collection from phpStorm but nothing show that support http verb change.
Yes, it does:
You can use whatever request method you need except for custom ones.

Propagate user-agent header with IBM API Connect

Is there a way to propagate the user-agent header with IBM API Connect?
I am proxying a REST/JSON service, and the user-agent is getting replaced with "IBM-APIConnect/5.0".
I need it for tracking purposes.
You should be able to achieve this using the set-header policy in your API assembly, though you need to ensure you're using the invoke policy to hit your backend endpoint rather than the proxy policy.
Before the the invoke policy, add a set-variable policy. Configure it as follows:
Action: Set
Set: user-agent
Value: $(request.headers.user-agent)
This will grab the incoming user agent header value from the request and force it to override the API Connect default.

Fiddler is not capturing libgit2 traces

I am using libgit2 to push my repository to server. But Fiddler not capturing HTTP/HTTPS traces during push operation.
Which protocol(git, http or winhttp) libgit2 uses to push reporsitory when we provide basic auth credentials ?
Why Fiddler not capturing libgit2 traces ?
Fiddler sets up your browser's default proxy, but does not necessarily set the proxy for other applications. libgit2 uses WinHTTP (on Windows) and thus uses its proxy settings which do "not inherit browser proxy settings. WinHTTP does not share any proxy settings with Internet Explorer."
You will need to either set the WinHTTP proxy when using fiddler, via netsh, or simply set the core.httpproxy and core.httpsproxy settings in your repository.