Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect Behavior Unexpected Using Digital Ocean with Caddy #2743

Open
mwood23 opened this issue Aug 17, 2019 · 6 comments
Open

Redirect Behavior Unexpected Using Digital Ocean with Caddy #2743

mwood23 opened this issue Aug 17, 2019 · 6 comments
Assignees
Labels
c/server Related to server

Comments

@mwood23
Copy link

mwood23 commented Aug 17, 2019

Description

For my web app, I want to be able to create a reverse proxy and place all of Hasura behind api instead of the root of my domain (since that's where my app is served from). When I followed the docs, I couldn't get it to work from /api.

Recreation Steps

My Caddy config

my-domain.com {
    proxy /api graphql-engine:8080 {
        websocket
    }
}

Result
{"path":"$","error":"resource does not exist","code":"not-found"}

After talking in the chat, all you have to do is add without /api after websocket leaving you this:

my-domain.com {
    proxy /api graphql-engine:8080 {
        websocket
        without /api
    }
}

This should give you access to the console at my-domain.com/api/console. However, if you go to my-domain.com/api, it redirects you to my-domain.com/console. If you add a trailing slash (my-domain.com/api), it redirects as expected.

@marionschleifer marionschleifer added dependencies Pull requests that update a dependency file k/question and removed dependencies Pull requests that update a dependency file labels Aug 19, 2019
@shahidhk
Copy link
Member

This is a confirmed behaviour, which is not ideal.

We should issue the right redirect irrespective of the trailing slash.

@shahidhk shahidhk added c/server Related to server and removed k/question labels Aug 21, 2019
@marionschleifer marionschleifer assigned dsandip and unassigned shahidhk Aug 21, 2019
@marionschleifer marionschleifer assigned 0x777 and unassigned dsandip Sep 8, 2019
@kevinmarrec
Copy link

kevinmarrec commented Jul 20, 2020

@marionschleifer Seems the task have been assigned multiple times to someone different but no updates ?

It seems this issue also affect Kubernetes when using an Ingress Controller and specifying we want Hasura on a specific path :

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /custom
        backend:
          serviceName: hasura
          servicePort: 8080

example.com/custom leads to {"path":"$","error":"resource does not exist","code":"not-found"}

I think it's overall in all cases we want Hasura on someting different from root /, that the issue happens.

Here is the error output of Hasura :

{
   "type": "http-log",
   "timestamp": "2020-07-20T21:57:04.445+0000",
   "level": "error",
   "detail": {
      "operation": {
         "error": {
            "path": "$",
            "error": "resource does not exist",
            "code": "not-found"
         },
         "request_id": "a4544567-b2db-4b6f-bc70-82dd1ee7b31d",
         "response_size": 65,
         "raw_query": ""
      },
      "http_info": {
         "status": 404,
         "http_version": "HTTP/1.1",
         "url": "/custom",
         "ip": "X.X.X.X",
         "method": "GET",
         "content_encoding": null
      }
   }
}

@gunar
Copy link

gunar commented Aug 14, 2020

Me too! I'd like to have Hasura live under a different URL path as well. Although, to be honest, I know this is something quite specific and I'd totally understand if this feature is never implemented.

Here's my scenario:

  • Reverse proxy (e.g. api gateway) points customdomain.com/console to hasura/
  • Going to customdomain.com/console gets me an infinite redirect
  • Going to customdomain.com/console/ gets me to customdomain.com/console/console (and shows the console)
  • Going to customdomain.com/console/ takes me tocustomdomain.com/console/console (and shows the console)
  • The console, when displayed, isn't working because the console is pointing GraphiQL to customdomain.com/console/v1/graphql (but it should be pointing to customdomain.com/console/console/v1/graphql).

The specific scenario above is irrelevant. What matters is that it would be solved by having a server flag that tells Hasura under which url path it is being served. Anyway, the solution specific to AWS API Gateway is to use route type http instead of http_proxy—my immediate problem is solved. May this help someone.

@jkaliaSignify
Copy link

I would like to know if there any solutions to this?

@jkaliaSignify
Copy link

@kevinmarrec did you figure anything out to get this working? please guide 😄

@jkaliaSignify
Copy link

jkaliaSignify commented Jun 3, 2021

Dunno about caddy but in nginx ingress we have to use regex for path re-writes

sample yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: testops
  labels:
    name: testops
  annotations:
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: "/$1"
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: testops.com
    http:
      paths:
      - pathType: Prefix
        path: /address/(.+)
        backend:
          service:
            name: graphql-engine
            port: 
              number: 9000        

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/server Related to server
Projects
None yet
Development

No branches or pull requests

8 participants