How to parse an HAProxy URL using logging or other tools - haproxy

Recently I had to debug a 404 on HAProxy. After a couple of hours of digging I found out that the acls in place had a rule which captured my URL pattern before the acl I intended to use for that pattern.
All well and good but then it occurred to me that there must be a way to configure either HAProxy logging or use an external tool whereby I give it a URL and it demonstrates the logic of which HAProxy would parse it and which rule would catch it first and where will it send it to. Something like EXPLAIN in postgres where it walks you through how the SQL query is being processed and analysed.
I’ve checkout the logging documentation, it is quite rich indeed and quite possibly could provide what I’m after but I’m looking for a TL;DR option to be honest :)
Thanks I’m advance

There is not a way to test an entire configuration in the same way that EXPLAIN would do, but you can test each ACL one at a time to see if a value would match by using the HAProxy Runtime API command get acl.
More info and examples is here: https://www.haproxy.com/documentation/hapee/latest/api/runtime-api/get-acl/

Related

Setting up REST-API on top of GraphQL-API (using apollo gateway?)

I am working on a GRANDstack (GraphQL-React-Apollo-Neo4jDatabase) project and got told that it now needs an additional REST-API without making huge changes to the existing backend and GraphQL-API. And of course we have to be quick about it.
We found this (Apollo Gateway): https://medium.com/tkssharma/an-api-gateway-is-a-microservice-pattern-where-a-separate-service-is-built-to-sit-in-front-of-your-be4b16861d40
We plan on using this to set that new REST-API on top because we know we will need microservices soon enough as well. So I guess, this can be set up in some form with the already included Apollo. But I have yet to fully understand it.
Does anyone have some experience with this? Or does anyone know a project that implements this and can be checked out? I'd like more material about this that contains actual code. Especially about setting up such a gateway to put a REST-API on top.
If there is something easier and better documented than this Apollo gateway, please let me know! Open to ideas, but not complete overkills (Though we are not allowed to just put REST directly into our backend, it has to stay quite untouched).
Thank you very much!
In short: Our current backend offers GraphQL-API which works just fine. But one of our customers (in this picture "client") needs a REST-API. So we hope on using a gateway (?) which should be placed before/upon our backend in a separate docker container probably, takes in HTTP-requests from the user and then asks our backend in graphQL for the needed data.
If anyone ever stumbles upon this, we decided to do the following:
Since we have to be quick about it, we will set up another docker container, that contains a small server, which accepts data via a REST-API. Depending on the received data, it calls specific GraphQL-Queries/Mutations on our backend. Easy. No additional 3rd-party software. Simple just wins.
Have a good one!

Next.js and aws-amplify deployment problem with aws-exports.js

I am new to web development, and the react/next/amplify ecosystem, but I have been playing around with it and it seems great. I am just having difficulties deploying my app. It seems to be an order of operations thing I might be doing wrong with the initial configuration, I am not sure.
So I followed the 5-minute tutorial on how to set Next.js up with aws-amplify using the git based deployment (so no amplify init), I then started to follow along with the todo tutorial for aws-amplify that I had previously completed, which included the aws-exports.js file. I could not deploy it because I was getting an import error for not being able to resolve ./aws-exports, which made sense because it wasn't there. I eventually performed a amplify init and had a copy, but found this is in the .gitignore file so it still failed when I tried to deploy. I took it out of my .gitignore just to see and voila a successful build.
This seemed wrong to me because why would it be in the .gitignore if it wasn't supposed to be?
I found this post that says the info is sensitive, but the documentation says otherwise.
This file is consumed by the Amplify JavaScript library for
configuration. It contains information which is non-sensitive and only
required for external, unauthenticated actions from clients (such as
user registration or sign-in flows in the case of Auth) or for
constructing appropriate endpoint URLs after authorization has taken
place.
So, can I leave this file out of the .gitignore? Is there a better way to do this? I experienced the same issue and solved it the same way deploying to Vercel, which may be my preferred deployment method bc of the easy lambda function integration (if that matters to the answer).
Thanks for any input.
Sorry for late to the party, I don't disagree with the doc which stated that aws-exports.js is non-sensitive, if you look into that file, it just bunch endpoints and nothing really enable you to "hack" into the system, unless you didn't config your #auth directive correctly. But I understand your concerns, and I don't like the style that endpoints are being exposed to clients in a single file, but they eventually will expose to user, either from the network tab or your code where you reference the endpoint.
A good reason that you should include aws-exports.js in your .gitignore is that you don't want to deal with conflicts in git, since this file will be auto-generated during build time.
If you using server-side rendering, seems like you are by using next.js, you can easily acchive only expose what is needed for client, I won't get into it as that's another topic.

How to add devices using openHAB REST API

I am looking for a way to discover a USB zstick "/dev/ttyACM0" using OpenHab command line interface as I am not going to be using a GUI and I need to create a script to automate few things.
In their website here and here OpenHab have some documentation, and that's what I found for discovery:
GET /discovery
POST /discovery/bindings/{bindingId}/scan
however I was unable to make that into a useful curl command. any idea on where to start?
I would suggest to try out the REST Documentation, for finding the right endpoint/expression.
You can install it through paper ui:
It will then be available through <YOUR_OH_IP>:<PORT>/doc/index.html.
It provides some ui with explanations and examples for the endpoints and you can test them live through it.
This should help you find the correct rest call to use with curl afterwards.
I don't know if adding devies through REST is possible. If so you can find it in the REST Documentation.
If it doesn't work though the REST API you might want to write a small bash script which adds the things you want. Then you can call your script with
executeCommandLine in a rule

Cakephp 3.1 REST - Filtering data

I have setup my application for REST access as per documentation. The default routes are working well. I am able to retrieve, update and delete records, however, I am not sure how I could filter data sending parameters to the controller. I wonder if I can do that using querystring or if there is a better way to accomplish that. Please can someone give me directions?
Reads about the Request object in the manual. And use the Search Plugin for filtering.
The search plugin comes with a lot of documentation that explains how to use it as well.
Your question is so generic that a proper answer would end up in a whole article - which I'm obviously not going to write, there is enough information available on HTTP requests and query params. Use Google or read these links:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages
https://www.w3.org/Protocols/HTTP/Request.html

implementing autocomplete in my website

i am developing a website where i intend to provide the search feature. I am developing it in PHP/MYSQL and i have written the script to perform the search. I wish to provide autocomplete or suggested searches option in the search box as the user types, can i know what are my choices and how can i make use of them?
I had tried YUI Autocomplete, it looks good to me, however i do not understand when it says using a local proxy for the datasource. Can any one help me out here?
Consider trying the Scriptaculous autocomplete. It's very easy to implement.
what does it exactly say on the documentation? (can you provide a link)
by local proxy I would think it means a proxy to a remote web service or API on another domain. (you can't make requests unless scripts are executed on the same domain). http://developer.yahoo.com/javascript/howto-proxy.html
I used jQuery autocompletex