How to capture cookies on haproxy logs? - cookies

Good day!!
I am pretty new to HA Proxy and I am trying to log all http details using httplog option. Where I am able to capture all the details except cookie request and response. I need to capture them to be able to understand users behaviour on our websites.
I have found some reference on google like below,
capture cookie name len 10
note: I am using marathon-lb haproxy official docker image
I am not able understand what should I give at "name" so that it can capture ? or If there is any way to capture ?
thanks in advance for your help :)

To log cookies you'll need to capture as you note, where name is the name of the cookie you want to capture.
To log the captured cookies, you'll use
%CC #captured_request_cookie
%CS #captured_response_cookie
You will have to use the log-format option and create a custom log that includes those cookies.
Doc section https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#8.2.4

Related

How to use cognito:username at http proxy integration of HttpApi of AWS?

I want to use the variable named event.requestContext.authorizer.jwt.claims.cognito:username which is the result of JWT authorizer at the URI of http proxy integration of HttpApi(I mean not RestApi) of AWS , because I want to access the information of authorized user. The exposed api is like this.
https://xxxxxx.com/platform/pro/user/john
pro means production .
john is event.requestContext.authorizer.jwt.claims.cognito:username .
The management console said my input like this is error.
https://xxxxxx.com/platform/${stageVariables.stage}/user/${event.requestContext.authorizer.jwt.claims.cognito:username}
I think : is NG.
Please help me.
I just found this question by accident. I guess you solved this in the meantime, but in case it's still relevant, you need to put cognito:username in quotes and brackets, so instead of ${event.requestContext.authorizer.jwt.claims.cognito:username} use ${event.requestContext.authorizer.jwt.claims['cognito:username']}.

Create a redirect rule for Azure CDN in Verizon which adds /index.html to the end of URL

I created an Azure CDN under Verizon Premium Subscription in the Azure portal with an endpoint which points to my Azure Static Website URL.
I want to create a redirect rule in Azure Verizon engine which adds /index.html to the end of URL if no extension is specified or the last sing of URL is not a / symbol.
So far I tried to use (.+\/[^\.]\w+$) regex expression, you can see an example of how it works here
My first approach:
In this case, if you type the URL https://blah.com/foo/bar in the web browser
it doesn't change the URL however you are able to view some of the content of the existing file from https://blah.com/foo/bar/index.html but some of the links to resources are broken. Not sure why I'm not getting the 404 in this case but maybe its because that I set the Index document name to index.html in the Static Website panel in the Storage account panel in Azure. If I open the Network tab in the developer tools of Chrome I can see a lot of 404 responses e.g.
And its because the website tries to get resources from the https://blah.com/foo/ directory instead of https://blah.com/foo/bar/
So, for example, the loadcsh.js in fact is located under the https://blah.com/foo/bar/loadcsh.js but the website is searching for the file under the wrong directory https://blah.com/foo/loadcsh.js
My second approach
In this case, if you type the URL https://blah.com/foo/bar
it makes a redirect to https://blah.com/foo/bar/foo/bar/index.html
so the foo/bar/ is redundant here.
My third approach
In this case, if you type the URL https://blah.com/foo/bar
it makes a redirect to https://blah.com/index.html
I have no idea how to apply the rule which makes a redirect from https://blah.com/foo/bar
to https://blah.com/foo/bar/index.html and is generic for all such cases.
Any ideas??
Cheers
I think your Regex expression is ok. You can add the rule URL redirect, in the Source textbox you type your Regex expression (.+\/[^\.]\w+$) and in the Destination textbox add https://%{host}/$1/index.htm. Here I used the HTTP variable for Azure CDN which can be used in Verizon. You can read more about the variables here.
In short words the %{host} returns a host name e.g. www.contoso.com
Please keep in mind all rule changes will require couple of hours propagation before it takes an effect on the CDN.

URLs of Azure Static Website should work without trailing /

I've created an Azure Static Website which works based on the Azure Blob Storage.
To be able to manage the automatic redirect from HTTP to HTTPs I created Azure CDN with Azure Verizon Premium subscription and I created an endpoint which
points to the URL of the static website. I followed the steps from this tutorial
If you hit the URL e.g.
https://blah.com/foo/
You will be automatically redirected to
https://blah.com/foo/index.html
This is because I set the Index document name to index.html in the Static website configuration panel.
What I want to achieve is to add the /index.html symbol to the very end of URL if it doesn't have an extension e.g.
https://blah.com/foo
https://blah.com/bar/foo
The expected result would be a redirect to:
https://blah.com/foo/index.html
https://blah.com/bar/foo/index.html
So my idea was to open the https://cdn.windowsazure.com/http/rules/default.aspx and try to create a new Rule; feature-> URL Redirect. In the TextBox near the Source label, I tried to specify the condition using Regex expression ^[^.]+$ which checks if the path contains a . If yes then it would mean the URL points to file with extension and the /index.html should be added to the end of URL. I think my Regex expression is wrong and should be different. Or maybe it is not the best way to achieve what I want?
Any ideas?
Cheers
So I tried almost everything and in the end, after adding this rule the Azure Static Webiste worked as expected:
Just further to this as I know it has an accepted answer but you won't need any redirect rule for index.html if you use a custom origin and use the static website's primary endpoint (will be something like .z8.web.core.windows.net/). For whatever reason, the CDN will treat that as a web server rather than a vanilla storage place.

CookieManager.check.cookies=false not working

I jmeter.properties I set "CookieManager.check.cookies=false" but cross domain cookies still aren't working.
For example going this guide and using their demo site setting a cookie with a domain of "blazedemo.com" works, but if I change the domain to anything else it fails.
JMeter sends only cookies that match the domain of server in the request.
The property you've set impact the way JMeter read cookies not the way it writes them.
To check, emit a http request towards one host for which you created the cookie, you'll see it works.

View cfhttp request

I would like to view the actual http request that gets sent via my cfhttp tag. What is the best tool to capture this?
Specially, I want to see exactly what headers and content are being sent.
To expand on what Edward has said and to answer your question about how you can view a request on ColdFusion;
Create a page that simply dumps everything out from GetHttpRequestData().
Have a look at the livedocs on getHttpRequestData() for more information.
Use Charles http proxy. Add the proyport and proxyhost attribute that points to your running instance of Charles. Caveat is that your machine will need to be reachable, and the port open for the server to reach.
I'd use sniffer if other side is also CF/Java based server http://kb2.adobe.com/cps/193/tn_19352.html