question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redirect Behavior Unexpected Using Digital Ocean with Caddy

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
kevinmarreccommented, 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
      }
   }
}
0reactions
jkaliaSignifycommented, 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        
Read more comments on GitHub >

github_iconTop Results From Across the Web

DigitalOcean is not redirecting website address to the droplet
Everything seems to be working just fine but you are redirecting your http traffic to https and it looks like that you have...
Read more >
How to fix Infinite Redirect Loop with WordPress Site ...
Right now i've got a WordPress site living on DigitalOcean by way of RunCloud. DNS is managed by CloudFlare and have an A...
Read more >
How To Host a Website with Caddy on Ubuntu 18.04
In this tutorial, you'll build Caddy from source using xcaddy, a custom Caddy builder tool, and use it to host a website secured...
Read more >
How To Host a Website with Caddy on Ubuntu 22.04
The tls directive configures Caddy's behavior when using TLS and you order it to use the digitalocean plugin for setting DNS records and ......
Read more >
Untitled
Kalmoohi episode 20, Appropriate non-verbal behavior, Mountjoy cemetery ... Niu wrestling room, Redirect asp page using javascript, Pflanzenanatomie.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found