Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: In log and mod_status http/2 requests are showed as http/1.1 |
|
Author |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Mon 21 Sep '15 14:08 Post subject: In log and mod_status http/2 requests are showed as http/1.1 |
|
|
Steffen wrote: | - In access log and mod_status http/2 requests are still showed as http/1.1 |
As for the logging, if you study you LogFormat you will see that all that inside the quotes ("GET /server-status HTTP/1.1") is all part of %r which is "First line of request" and is very similar to what you also see in server-status which is very similar to your request header from the browser.
Browsers always send HTTP/1.1 requests, they then upgrade to any http/2 protocol if the server says it's available. You can see this in Curl;
Code: | * Connected to localhost (127.0.0.1) port 80 (#0)
> HEAD / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.44.0
> Accept: */*
> Connection: Upgrade, HTTP2-Settings
> Upgrade: h2c
> HTTP2-Settings: AAMAAABkAAQAAP__
>
< HTTP/1.1 101 Switching Protocols
< Upgrade: h2c
< Connection: Upgrade
Connection: Upgrade
* Received 101
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=27
* http2_recv: 16384 bytes buffer at 0x19b45e4 (stream 1)
* http2_recv: returns 236 for stream 1
< HTTP/2.0 200
HTTP/2.0 200 |
Your best bet for getting HTTP/2 to show in your logs (it will still show HTTP/1.1 also) is to add %{SERVER_PROTOCOL}e to the end of your LogFormat sting where it will not break any log readers.
Edit: or better yet, just duplicate %r with the envvars so it shows HTTP/2 and does not break any log reader you may use. Code: | - LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
- LogFormat "%h %l %u %t \"%r\" %H %>s %b" common
+ LogFormat "%h %l %u %t \"%{REQUEST_METHOD}e %{REQUEST_URI}e %{SERVER_PROTOCOL}e\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
+ LogFormat "%h %l %u %t \"%{REQUEST_METHOD}e %{REQUEST_URI}e %{SERVER_PROTOCOL}e\" %H %>s %b" common |
I'll look into doing same in mod_status but again it will still show the original request protocol HTTP/1.1.
My gripe originally was that the envvar still showed HTTP/1.1 but that got fixed. |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3093 Location: Hilversum, NL, EU
|
Posted: Mon 21 Sep '15 14:38 Post subject: |
|
|
I added %{SERVER_PROTOCOL}e , but it showing a -
Added now %H and then it shows !
Thanks given me the direction. |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Mon 21 Sep '15 15:12 Post subject: |
|
|
I did a quick hatchet job on mod_status, haven't tried it but a couple refreshes and it seems to work.
Edit: Link removed, see below post for the new approach.
Last edited by glsmith on Wed 23 Sep '15 11:53; edited 1 time in total |
|
Back to top |
|
admin Site Admin
Joined: 15 Oct 2005 Posts: 692
|
Posted: Mon 21 Sep '15 17:10 Post subject: |
|
|
With h2c (over http, not supported by my known browsers) you see in your log also a line with status code 101 (switching protocols):
With Curl:
www.apachelounge.com 2001:980:a510:1:d571:caed:72a0:9e9b - - [21/Sep/2015:17:05:31 +0200] "GET /index.php HTTP/1.1" 200 22972 "-" "curl/7.44.0" HTTP/2
www.apachelounge.com 2001:980:a510:1:d571:caed:72a0:9e9b - - [21/Sep/2015:17:05:31 +0200] "GET / HTTP/1.1" 101 - "-" "curl/7.44.0" HTTP/1.1 |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Wed 23 Sep '15 11:56 Post subject: |
|
|
admin wrote: | With h2c (over http, not supported by my known browsers) you see in your log also a line with status code 101 (switching protocols) |
I think this is by design. I need to look through protocol.c in the current 2.4 branch to know for sure if this was added or always has been there. |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Wed 23 Sep '15 12:12 Post subject: |
|
|
Logging HTTP/2:
I finally tested my theory and this does work sort of
LogFormat "%h %l %u %t \"%{REQUEST_METHOD}e %{REQUEST_URI}e %{SERVER_PROTOCOL}e\" %>s %b" common
10.0.0.33 - - [23/Sep/2015:01:09:19 -0700] "GET /switch.pl HTTP/2" 200 156
But I'm seeing these as well
fe80::85de:5210:3f0:ee27 - - [23/Sep/2015:01:40:26 -0700] "- - -" 200 3414
10.0.0.33 - - [23/Sep/2015:01:41:23 -0700] "- - -" 200 3391
10.0.0.33 - - [23/Sep/2015:01:41:23 -0700] "- - -" 101 -
I think the best thing would be to just add %{SERVER_PROTOCOL}e after the \"%r\"
LogFormat "%h %l %u %t \"%r\" %{SERVER_PROTOCOL}e %>s %b" common
HTTP/1.1 101 Switching Protocols
Upgrade: h2c
Connection: Upgrade
HTTP/2.0 200
date:Wed, 23 Sep 2015 10:03:13 GMT
server:Apache/2.4.17-dev (Win32) OpenSSL/1.0.2d
127.0.0.1 - - [23/Sep/2015:03:03:13 -0700] "GET /index.html HTTP/1.1" HTTP/2 200 801
Of course you will see http/1.1 listed twice for non h2/h2c requests. You could also use <If> and check for http/2 in %{SERVER_PROTOCOL}e. If it's not HTTP/2 then just print a - for a place holder to keep format the same either way.
Last edited by glsmith on Wed 23 Sep '15 12:26; edited 1 time in total |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Wed 23 Sep '15 12:21 Post subject: |
|
|
New mod_status attempt.
Code: | #Srv PID Acc M SS Req Conn Child Slot Client VHost Request RsProto
#0-0 4280 0/3/3 R 0 0 0.0 0.01 0.01 ::1 localhost:443 GET /server-status HTTP/1.1 HTTP/2
#
Index: modules/generators/mod_status.c
===================================================================
--- modules/generators/mod_status.c (revision 1704784)
+++ modules/generators/mod_status.c (working copy)
@@ -663,7 +671,7 @@
"<th>SS</th><th>Req</th>"
"<th>Conn</th><th>Child</th><th>Slot</th>"
"<th>Client</th><th>VHost</th>"
- "<th>Request</th></tr>\n\n", r);
+ "<th>Request</th><th>RsProto</th></tr>\n\n", r);
for (i = 0; i < server_limit; ++i) {
for (j = 0; j < thread_limit; ++j) {
@@ -861,14 +869,17 @@
(float)bytes / MBYTE);
ap_rprintf(r, "</td><td>%s</td><td nowrap>%s</td>"
- "<td nowrap>%s</td></tr>\n\n",
+ "<td nowrap>%s</td><td>%s</td></tr>\n\n",
ap_escape_html(r->pool,
ws_record->client),
ap_escape_html(r->pool,
ws_record->vhost),
ap_escape_html(r->pool,
ap_escape_logitem(r->pool,
- ws_record->request)));
+ ws_record->request)),
+ ap_escape_html(r->pool,
+ ap_escape_logitem(r->pool,
+ r->protocol)));
} /* no_table_report */
} /* for (j...) */
} /* for (i...) */
|
|
|
Back to top |
|
|
|
|
|
|