How to proxy requests in docker swagger ui - docker

I'm using Swagger UI using its docker version. The Try it out button is not working as expected from the Web UI because there's a problem with cors. I'm running the UI from localhost and doing requests to another domain. I have read this other question How to avoid CORS errors ("Failed to fetch" or "Server not found or an error occurred") when making requests from Swagger Editor? but I cannot do any of the solutions it says.
I'm not sure if it's posible to setup a proxy on the docker container as SwaggerHub does, like, instead of the Try it out request be resolved on the browser, resolve it on the docker container.
Do you know if that is posible?

Related

Cookies are not set on Vue.js and probably caused by CORS

I am creating an application using Vue.js with Vite for client-side and express.js for the server-side on docker. The server side sends the cookie as a response to Axios request front client, and I can see Set-cookie in the response-header. However, this cookie is not set to the browser. I opened the Application tab and checked the cookie, but nothing was there.
Client URL: http://localhost:3000/
Server URL: http://localhost:15173/
Both of the are running on separate Docker containers.
Environment is
Front: vue3 with vite
Sererside: nodejs with express.js
connection: Using axios
Probably, this is caused by CORS, but I don't know how to deal with that. I'm tring to solve this question fixing proxy, but so far no luck.
if anyone can help me out, that would be great. Thank you!
I tried vite.config proxy setting, but it didn't solve the situation.

Can't send HTTP Request from inside a docker container

I have a java application as JAR. This JAR application runs fine from my machine, meaning it can send and receive HTTP Requests to and from an API Endpoint (let's call this endpoint example.com/api/).
And then i built a docker image of this JAR Application, and tried to run the image as container from my docker desktop. But then i got this error.
the error i got
it seems like my application cant reach the url from inside the docker container. I tried to set the proxy in Settings -> Resources -> Proxies -> Manual proxies configuraton, and put my company proxy since i'm inside my company network. But still it doesn't work.
I tried to google this problem but almost nothing shows up (anything that shows up have little correlation with my problem). Anyone knows what seems to be the problem? What should I do?
First check if your container is able to communicate with the endpoint. Ping or curl it from the container shell. If you use proxy, set environment variables in container:
export http_proxy=http://server-ip:port
export https_proxy=https://server-ip:port

How to connect via http instead of default https on nifi docker container

I am currently running latest versions Nifi and Postgresql via docker compose.
as of 1.14 version update of Nifi, when you accesss the UI on web it connects via https, thus asking you for ID and Password every time you log in. Its too cumbersome to go to nifi-app.log file and look for credentials every time I access the UI. I know that you can change the setting where it keeps https as the default method but I am not sure how to do that in a docker container. Can anyone help me with this?
You could use some env like AUTH in the documentation
You can find the full explanations here

Cannot access Keycloak account-console in Kubernetes (403)

I have found a strange behavior in Keycloak when deployed in Kubernetes, that I can't wrap my head around.
Use-case:
login as admin:admin (created by default)
click on Manage account
(manage account dialog screenshot)
I have compared how the (same) image (quay.io/keycloak/keycloak:17.0.0) behaves if it runs on Docker or in Kubernetes (K3S).
If I run it from Docker, the account console loads. In other terms, I get a success (204) for the request
GET /realms/master/protocol/openid-connect/login-status-iframe.html/init?client_id=account-console
From the same image deployed in Kubernetes, the same request fails with error 403. However, on this same application, I get a success (204) for the request
GET /realms/master/protocol/openid-connect/login-status-iframe.html/init?client_id=security-admin-console
Since I can call security-admin-console, this does not look like an issue with the Kubernetes Ingress gateway nor with anything related to routing.
I've then thought about a Keycloak access-control configuration issue, but in both cases I use the default image without any change. I cross-checked to be sure, it appears that the admin user and the account-console client are configured exactly in the same way in both the docker and k8s applications.
I have no more idea about what could be the problem, do you have any suggestion?
Try to set ssl_required = NONE in realm table in Keycloak database to your realm (master)
So we found that it was the nginx ingress controller causing a lot of issues. While we were able to get it working with nginx, via X-Forwarded-Proto etc., but it was a bit complicated and convoluted. Moving to haproxy instead resolved this problem. As well, make sure you are interfacing with the ingress controller over https or that may cause issues with keycloak.
annotations:
kubernetes.io/ingress.class: haproxy
...

How to enable CORS in Nifi running in Docker?

I'm having a problem accessing the nifi API from a web app I'm building. This is the error I get:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at ...
I know I need to enable CORS on the jetty server nifi runs on, and I've changed the web.xml in an attempt to do this. But every time I rebuild the image and stand up a container, all of my changes are overwritten. Is there an easier way to accomplish enabling CORS so that I can access the nifi api with my webapp? Or is there any insight on how to make my changes persist in the web.xml files on the docker container startup?

Resources