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

fix(plugins): traefik configuration parsing #305

Merged
merged 2 commits into from
Feb 13, 2023
Merged

fix(plugins): traefik configuration parsing #305

merged 2 commits into from
Feb 13, 2023

Conversation

jonasengelmann
Copy link
Contributor

Closes #304

@jonasengelmann
Copy link
Contributor Author

Although now POST requests can be cached, I noticed that sending a POST request with a body leads to an error 500 using a whoami test setup.

Copy link
Owner

@darkweak darkweak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after the little fix.

README.md Outdated Show resolved Hide resolved
@darkweak
Copy link
Owner

I noticed that sending a POST request with a body leads to an error 500 using a whoami test setup.

Does the 500 HTTP response code comes from the whoami service or Souin itself?

@jonasengelmann
Copy link
Contributor Author

Does the 500 HTTP response code comes from the whoami service or Souin itself?

I am not so sure, I think it comes from Souin although there is no error message in the logs.

This is my test setup:

version: "3.8"
services:
  traefik:
    image: traefik:v2.7.0
    command:
      - --providers.docker=true
      - --entrypoints.web.address=:80
      - --experimental.localPlugins.souin.moduleName=github.com/darkweak/souin
    ports:
      - 80:80
    networks:
      - default
    volumes:
      - ./souin:/plugins-local/src/github.com/darkweak/souin
      - /var/run/docker.sock:/var/run/docker.sock:ro

  whoami:
    image: traefik/whoami:latest
    labels:
      - traefik.enable=true
      - traefik.http.routers.whoami.rule=Host(`localhost`)
      - traefik.http.routers.whoami.entrypoints=web
      - traefik.http.middlewares.http-cache.plugin.souin.api.souin
      - traefik.http.middlewares.http-cache.plugin.souin.default_cache.ttl=10s
      - traefik.http.middlewares.http-cache.plugin.souin.default_cache.allowed_http_verbs=POST,GET,HEAD
      - traefik.http.middlewares.http-cache.plugin.souin.log_level=debug
      - traefik.http.routers.whoami.middlewares=http-cache

curl -X POST -i http://localhost -H "Content-Type: application/json" -d '{"test": 1}'

Returns:

HTTP/1.1 500 Internal Server Error
Cache-Status: Souin; fwd=uri-miss; key=POST-localhost-/-459abcffc7b40c78ff8941f8c6139ae4208247022299bd8f13dad5f40efdb567; detail=NOT-CACHEABLE
Date: Fri, 10 Feb 2023 20:36:23 GMT
Content-Length: 21
Content-Type: text/plain; charset=utf-8

Internal Server Error⏎    

In the traefik logs I can only find this:
level=debug msg="'500 Internal Server Error' caused by: net/http: HTTP/1.x transport connection broken: http: ContentLength=11 with Body length 0"

However, sending the same curl request to whoami without Souin as middleware returns this:

Content-Length: 403
Content-Type: text/plain; charset=utf-8
Date: Fri, 10 Feb 2023 20:44:29 GMT

Hostname: 36772703e6b3
IP: 127.0.0.1
IP: 172.18.0.2
RemoteAddr: 172.18.0.3:38002
POST / HTTP/1.1
Host: localhost
User-Agent: curl/7.85.0
Content-Length: 11
Accept: */*
Accept-Encoding: gzip
Content-Type: application/json
X-Forwarded-For: 172.18.0.1
X-Forwarded-Host: localhost
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Server: f83398e7cec5
X-Real-Ip: 172.18.0.1

{"test": 1}⏎    

Any idea?

@darkweak
Copy link
Owner

I dunno why that behavior happens. I'll have a look at that once I finish my work on the middleware refactoring (FYI master...feat/chore/refactoring-to-middleware-philosophy).
IMHO we can merge your PR. Great job @jonasengelmann 👍

@darkweak darkweak merged commit c0690a6 into darkweak:master Feb 13, 2023
@darkweak
Copy link
Owner

Thank you for your contribution @jonasengelmann 🚀

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

Successfully merging this pull request may close these issues.

[Traefik Plugin] Setting default_cache.allowed_http_verbs does not seem to work
2 participants