HTTP2 without TLS
See original GitHub issueThe README explains how to set up HTTP2 with TLS, but there’s no indication of how to set it up without TLS.
Just for context: my interest in doing this is because my load balancer already does the TLS termination. There’s little sense in me setting up a pipeline to provision certificates to my django instances – and the overhead of TLS between the load balancer and Django doesn’t really make sense.
I’ve installed the optional dependencies:
pip install -U 'Twisted[tls,http2]'
And daphne
indicates it supports HTTP2:
root@e4376f859b81:/app# bash scripts/run-django
[ DEBUG 2020-11-02 12:09:40] django.request:120 Asynchronous middleware django.middleware.clickjacking.XFrameOptionsMiddleware adapted.
[ DEBUG 2020-11-02 12:09:40] asyncio:59 Using selector: EpollSelector
[ INFO 2020-11-02 12:09:40] daphne.cli:287 Starting server at tcp:port=8000:interface=0.0.0.0
[ INFO 2020-11-02 12:09:40] daphne.server:108 HTTP/2 support enabled
[ INFO 2020-11-02 12:09:40] daphne.server:119 Configuring endpoint tcp:port=8000:interface=0.0.0.0
[ INFO 2020-11-02 12:09:40] daphne.server:150 Listening on TCP address 0.0.0.0:8000
However, it does not seem to actually operate on HTTP2, even using things like:
❯ curl -vI HEAD --http2 http://www.myapp.localhost:8000/
* Could not resolve host: HEAD
* Closing connection 0
curl: (6) Could not resolve host: HEAD
* Trying ::1:8000...
* Connected to www.myapp.localhost (::1) port 8000 (#1)
> HEAD / HTTP/1.1
> Host: www.myapp.localhost:8000
> User-Agent: curl/7.73.0
> Accept: */*
> Connection: Upgrade, HTTP2-Settings
> Upgrade: h2c
> HTTP2-Settings: AAMAAABkAAQCAAAAAAIAAAAA
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
Content-Type: text/html; charset=utf-8
< X-Frame-Options: DENY
X-Frame-Options: DENY
< Vary: Cookie, Accept-Language
Vary: Cookie, Accept-Language
< Content-Length: 433909
Content-Length: 433909
< Content-Language: es
Content-Language: es
Am I testing this wrong, or would additional changes be required for daphne to support this?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Why do web browsers not support h2c (HTTP/2 without TLS)?
Technically. There are several technical reasons why HTTP/2 is much better and easier to handle over HTTPS: Doing HTTP/2 negotiation in TLS ......
Read more >HTTP/2 Frequently Asked Questions
Can I implement HTTP/2 without implementing HTTP/1.1? ... Yes, mostly. For HTTP/2 over TLS ( h2 ), if you do not implement the...
Read more >Support HTTP/2 without TLS · Issue #503 · encode/httpx - GitHub
After some research it is true that HTTP/2 does not require encryption, but "currently no browser supports HTTP/2 unencrypted", and there seems ...
Read more >HTTP/2 without tls - Google Groups
HTTP2 supports both, decrypt and encrypt ways, however, browsers like Firefox ,Chrome, and IE, doesn't allowed this protocol without security protocols. Ref.
Read more >HTTP/2 Cleartext (H2C) Client Example in Go - Mailgun
First, in case you may be wondering what H2C is, it is essentially HTTP/2 but without TLS. H2C is understandably not widely publicized...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yup, I’m quite aware of this.
This is not my case though; I have daphne behind a load balancer. Using a LB or another proxy that does the TLS termination is not unusual.
@carltongibson It seems that this can be implemented by simply using a different Twisted endpoint class. Instead of using
SSL4ServerEndpoint
replace it withTCP4ServerEndpoint
. I’m referring to this Twisted example.