File: check-http2

package info (click to toggle)
apache2 2.4.66-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 59,500 kB
  • sloc: ansic: 212,331; python: 13,830; perl: 11,307; sh: 7,258; php: 1,320; javascript: 1,314; awk: 749; makefile: 715; lex: 374; yacc: 161; xml: 2
file content (41 lines) | stat: -rwxr-xr-x 1,200 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
set -uxe

# http2 is rather new, check that it at least generally works
# Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>

a2enmod http2
a2enmod ssl
a2ensite default-ssl
# Enable globally
echo "Protocols h2c h2 http/1.1" >> /etc/apache2/apache2.conf
service apache2 restart

# Use curl here. wget doesn't work on Debian, even with --no-check-certificate
# wget on Debian gives me:
#    GnuTLS: A TLS warning alert has been received.
#    Unable to establish SSL connection.
# Presumably this is due to the self-signed certificate, but I'm not sure how
# to skip the warning with wget. curl will do for now.
echo "Hello, world!" > /var/www/html/hello.txt

testapache () {
    cmd="${1}"
    result=$(${cmd})

    if [ "$result" != "Hello, world!" ]; then
        echo "Unexpected result: ${result}" >&2
        exit 1
    else
        echo OK
    fi
}

# https shall not affect http
testapache "curl -s -k http://localhost/hello.txt"
# https shall not affect https
testapache "curl -s -k https://localhost/hello.txt"
#plain http2
testapache "nghttp --no-verify-peer https://localhost/hello.txt"
#http2 upgrade
testapache "nghttp -u --no-verify-peer http://localhost/hello.txt"