MarquezProject / marquez

Collect, aggregate, and visualize a data ecosystem's metadata
https://marquezproject.ai
Apache License 2.0
1.78k stars 320 forks source link

marquez web proxy error #1735

Open dvirgiln opened 3 years ago

dvirgiln commented 3 years ago

I am receiving an error accesing the API from marquez web

[HPM] Error occurred while trying to proxy request /api/v1/namespaces from marquez-web-internal-eks.eu-west-1.dev.hbi.systems to http://marquez-internal-eks.eu-west-1.dev.hbi.systems:80/ (ECONNRESET)

My application is deployed in Kubernetes. There is a redirection from http to https.

The problem is happening here: https://github.com/MarquezProject/marquez/blob/main/web/setupProxy.js#L6

So first question is why http protocol is hardcoded here.

I made marquez web to work forking the code and creating my own image:

const apiOptions = {
  target: `https://${process.env.MARQUEZ_HOST}/`,
  secure: false,
  changeOrigin: true,
  headers: {
    "Connection": "keep-alive"
  }
}

I based my patch from this post: https://github.com/chimurai/http-proxy-middleware/issues/171

wslulciuc commented 2 years ago

@dvirgiln: Yeah, good point. The proxy server configuration assumes ssl termination at the ELB level (i.e. calls from the UI are made within the same VPC, thus not requiring ssl), but that's not always the case. I've added this issue to our roadmap to allow users to enable/disable ssl.

phixMe commented 9 months ago

I wouldn't be opposed to crafting a separate docker image for a more production like deploy with an nginx server for this kind of purpose. Maybe worth making an issue for this.

andyfase commented 9 months ago

Just adding to this. I honestly think the change needed is as simple as

const apiOptions = {
  target: `${process.env.MARQUEZ_PROTO ?? "http"}://${process.env.MARQUEZ_HOST}:${process.env.MARQUEZ_PORT}/`,
  changeOrigin: process.env.PROXY_CHANGE_ORIGIN?.toLowerCase()  === "true"
}

This remains default behaviour and allows for:

  1. HTTPS proxying via optional MARQUEZ_PROTO env
  2. Setting the correct HOST header when proxying to the API (when the API and Web are on different domains) via optional PROXY_CHANGE_ORIGIN env

Usage

docker run -p 3000:3000 -e MARQUEZ_HOST="marquez-api.foo.com" -e MARQUEZ_PORT="443" -e MARQUEZ_PROTO="https"  -e PROXY_CHANGE_ORIGIN="true" marquez-web