Giter Site home page Giter Site logo

caddy-uwsgi-transport's Introduction

caddy-uwsgi-transport's People

Contributors

dependabot[bot] avatar wxh06 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

badaimweeb

caddy-uwsgi-transport's Issues

unix socket support

does this support unix sockets? when trying:
Caddyfile

localhost
reverse_proxy /test {
        to unix//run/uwsgi/cgit.sock
        transport uwsgi
}

and curl -L localhost
I get

2023/08/23 20:15:45.406 ERROR   http.log.error  dial tcp: address /run/uwsgi/cgit.sock: missing port in address{"request": {"remote_ip": "::1", "remote_port": "36704", "client_ip": "::1", "proto": "HTTP/2.0", "method": "GET", "host": "localhost", "uri": "/tom", "headers": {"Accept": ["*/*"], "User-Agent": ["curl/8.2.1"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "server_name": "localhost"}}, "duration": 0.00010795, "status": 502, "err_id": "wsw39s1pf", "err_trace": "reverseproxy.statusError (reverseproxy.go:1248)"}

Unexpected EOF

uWSGI command:

uwsgi --ini /home/weblate.ini

weblate.ini

[uwsgi]
http = :3314
chdir = /home/Weblate/weblate
wsgi-file = /home/Weblate/weblate/wsgi.py
callable = application
processes = 4
threads = 2
master = true

My Caddyfile

:9090 {
	reverse_proxy 127.0.0.1:3314 {
		transport uwsgi
	}
}

HTTP 502, malformed HTTP version "Status:" - Caddy says

Greetings.
Caddy returns me 502 Bad Gateway when I'm trying to query an endpoint that caddy should proxy to an uwsgi server via uwsgi native protocol. I have boiled down the problem to minimal reproducible example: https://github.com/norohind/caddy-uwsgi-transport.

So, that how it looks from client side (-D - makes curl print out headers to stdout):

$ curl -D - http://127.0.0.1:8888
HTTP/1.1 502 Bad Gateway
Server: Caddy
Date: Tue, 28 Nov 2023 19:25:55 GMT
Content-Length: 0

At the same time in logs of caddy and uwsgi appear following lines

caddy-uwsgi-transport-issue-uwsgi-1  | [pid: 1|app: 0|req: 6/6] 172.22.0.1:57030 () {32 vars in 378 bytes} [Tue Nov 28 19:25:55 2023] GET  => generated 11 bytes in 0 msecs (HTTP/1.1 200) 1 headers in 43 bytes (4 switches on core 0)
caddy-uwsgi-transport-issue-caddy-1  | {"level":"error","ts":1701199555.950834,"logger":"http.log.error","msg":"malformed HTTP version \"Status:\"","request":{"remote_ip":"172.22.0.1","remote_port":"57030","client_ip":"172.22.0.1","proto":"HTTP/1.1","method":"GET","host":"127.0.0.1:8888","uri":"/","headers":{"User-Agent":["curl/8.4.0"],"Accept":["*/*"]}},"duration":0.001092797,"status":502,"err_id":"verjzexi7","err_trace":"reverseproxy.statusError (reverseproxy.go:1265)"}

As it can be seen, uwsgi receives the query and appears to respond, but caddy, for some reason, can't handle the response and thus returns to http query 502 code.

Most interesting part is this problem occurs only if uwsgi is run with config file (uwsgi.conf in the example). If you would
run uwsgi with cli args then everything works fine. Conveniently, in the example, I left an option to run uwsgi with the same parameters as in uwsgi.conf but as cli args (Details in Steps to reproduce).

Steps to reproduce

git clone https://github.com/norohind/caddy-uwsgi-transport.git
cd caddy-uwsgi-transport
docker-compose up  # This one shall build images and then run containers, logs going to be on stdout

# Now in separate shell query the uwsgi app through caddy
curl -D - http://127.0.0.1:8888  

Mystery with "equivalence" of cli args and config file

In docker-compose.yaml: Comment in line 22 and comment out line 21, then make docker-compose up --build.
Then query caddy again using curl and you should get 200 http response, although options provided to uwsgi in both cases seems to be identical.

Versions

  • caddy-uwsgi-transport: I believe it builds from the latest commit, as for now it is 573bdc411df6d73ea72730cd755324bbb3a0151b
  • Uwsgi (from logs): uWSGI 2.0.23 (64bit)
  • Caddy -v: v2.7.5 h1:HoysvZkLcN2xJExEepaFHK92Qgs7xAiCFydN5x5Hs6Q=
  • docker version:
Client:
 Version:           24.0.7
 API version:       1.43
 Go version:        go1.21.3
 Git commit:        tag v24.0.7
 Built:             Wed Nov  1 19:52:11 2023
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          24.0.7
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.21.3
  Git commit:       tag v24.0.7
  Built:            Wed Nov  1 19:52:11 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.8
  GitCommit:        UNSET
 runc:
  Version:          1.1.9
  GitCommit:
 docker-init:
  Version:          0.19.0
  GitCommit:
  • docker-compose -v: Docker Compose version v2.21.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.