envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.85k stars 4.78k forks source link

Incoming HTTP 1.0 traffic needs upgrade #4243

Closed dohnto closed 6 years ago

dohnto commented 6 years ago

Title: Incomming HTTP 1.0 request is refused by envoy with 426 http status

Description:

I try to use envoy as a proxy for incomming HTTP 1.0 requests. I set accept_http_10 according to documentation, but the envoy refuses to pass the requests and still returns 426 http status code.

Repro steps:

# cat conf/envoy.yaml 
static_resources:
  listeners:
  - address:
      socket_address:
        address: 0.0.0.0
        port_value: 80
    filter_chains:
    - filters:
      - name: envoy.http_connection_manager
        config:
          codec_type: auto
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: service
              domains:
              - "*"
              routes:
              - match:
                  prefix: "/"
                route:
                  cluster: local_service
          http_filters:
          - name: envoy.router
            config: {}
  clusters:
  - name: local_service
    connect_timeout: 0.25s
    type: strict_dns
    lb_policy: round_robin
    hosts:
    - socket_address:
        address: 127.0.0.1
        port_value: 8080
    http_protocol_options:
      accept_http_10: true
admin:
  access_log_path: "/dev/null"
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 8081
$ docker run -it --net=host -d -v $PWD/conf:/etc/envoy:ro envoyproxy/envoy:99df2e23423a8bb27eeca0c696de44a9dbb1f843
$ curl -i -0 localhost:80
HTTP/1.1 426 Upgrade Required
date: Fri, 24 Aug 2018 11:30:27 GMT
server: envoy
content-length: 0

Note: The Envoy_collect tool gathers a tarball with debug logs, config and the following admin endpoints: /stats, /clusters and /server_info. Please note if there are privacy concerns, sanitize the data prior to sharing the tarball/pasting.

Trying to use envoy_collect with provided yaml I got error:

# python envoy_collect.py -c envoy.yaml 
Traceback (most recent call last):
  File "envoy_collect.py", line 260, in <module>
    sys.exit(envoy_collect(*parser.parse_known_args(sys.argv)))
  File "envoy_collect.py", line 175, in envoy_collect
    parse_result.config_path, perf, envoy_tmpdir)
  File "envoy_collect.py", line 83, in modify_envoy_config
    envoy_config = json.loads(f.read())
  File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

When I convert yaml to json I got

usage: envoy_collect.py [-h] [--output-path OUTPUT_PATH] --config-path
                        CONFIG_PATH [--log-level LOG_LEVEL] [--performance]
                        [--envoy-binary ENVOY_BINARY]
envoy_collect.py: error: argument --config-path/-c is required
root@2dcb5b00b16c:/# python envoy_collect.py -c envoy.json 
Traceback (most recent call last):
  File "envoy_collect.py", line 260, in <module>
    sys.exit(envoy_collect(*parser.parse_known_args(sys.argv)))
  File "envoy_collect.py", line 175, in envoy_collect
    parse_result.config_path, perf, envoy_tmpdir)
  File "envoy_collect.py", line 87, in modify_envoy_config
    for n, listener in enumerate(envoy_config['listeners']):
KeyError: 'listeners'

Admin and Stats Output: stats.txt clusters.txt routes.txt server_info.txt

Logs:

[2018-08-24 11:34:44.598][9][info][main] source/server/server.cc:189] initializing epoch 0 (hot restart version=10.200.16384.127.options=capacity=16384, num_slots=8209 hash=228984379728933363 size=2654312)
[2018-08-24 11:34:44.598][9][info][main] source/server/server.cc:191] statically linked extensions:
[2018-08-24 11:34:44.598][9][info][main] source/server/server.cc:193]   access_loggers: envoy.file_access_log,envoy.http_grpc_access_log
[2018-08-24 11:34:44.598][9][info][main] source/server/server.cc:196]   filters.http: envoy.buffer,envoy.cors,envoy.ext_authz,envoy.fault,envoy.filters.http.header_to_metadata,envoy.filters.http.jwt_authn,envoy.filters.http.rbac,envoy.grpc_http1_bridge,envoy.grpc_json_transcoder,envoy.grpc_web,envoy.gzip,envoy.health_check,envoy.http_dynamo_filter,envoy.ip_tagging,envoy.lua,envoy.rate_limit,envoy.router,envoy.squash
[2018-08-24 11:34:44.598][9][info][main] source/server/server.cc:199]   filters.listener: envoy.listener.original_dst,envoy.listener.proxy_protocol,envoy.listener.tls_inspector
[2018-08-24 11:34:44.598][9][info][main] source/server/server.cc:202]   filters.network: envoy.client_ssl_auth,envoy.echo,envoy.ext_authz,envoy.filters.network.rbac,envoy.filters.network.thrift_proxy,envoy.http_connection_manager,envoy.mongo_proxy,envoy.ratelimit,envoy.redis_proxy,envoy.tcp_proxy
[2018-08-24 11:34:44.598][9][info][main] source/server/server.cc:204]   stat_sinks: envoy.dog_statsd,envoy.metrics_service,envoy.stat_sinks.hystrix,envoy.statsd
[2018-08-24 11:34:44.598][9][info][main] source/server/server.cc:206]   tracers: envoy.dynamic.ot,envoy.lightstep,envoy.zipkin
[2018-08-24 11:34:44.598][9][info][main] source/server/server.cc:209]   transport_sockets.downstream: envoy.transport_sockets.capture,raw_buffer,tls
[2018-08-24 11:34:44.598][9][info][main] source/server/server.cc:212]   transport_sockets.upstream: envoy.transport_sockets.capture,raw_buffer,tls
[2018-08-24 11:34:44.601][9][info][config] source/server/configuration_impl.cc:50] loading 0 static secret(s)
[2018-08-24 11:34:44.601][9][info][config] source/server/configuration_impl.cc:56] loading 1 cluster(s)
[2018-08-24 11:34:44.602][9][info][upstream] source/common/upstream/cluster_manager_impl.cc:134] cm init: all clusters initialized
[2018-08-24 11:34:44.602][9][info][config] source/server/configuration_impl.cc:61] loading 1 listener(s)
[2018-08-24 11:34:44.603][9][info][config] source/server/configuration_impl.cc:95] loading tracing configuration
[2018-08-24 11:34:44.603][9][info][config] source/server/configuration_impl.cc:117] loading stats sink configuration
[2018-08-24 11:34:44.603][9][info][main] source/server/server.cc:403] all clusters initialized. initializing init manager
[2018-08-24 11:34:44.603][9][info][config] source/server/listener_manager_impl.cc:908] all dependencies initialized. starting workers
[2018-08-24 11:34:44.604][9][info][main] source/server/server.cc:434] starting main dispatch loop
[2018-08-24 11:49:44.605][9][info][main] source/server/drain_manager_impl.cc:63] shutting down parent after drain
ggreenway commented 6 years ago

I think the error is that you set the http1.0 option on the cluster, not on the http connection manager. Try setting it here: https://www.envoyproxy.io/docs/envoy/latest/api-v2/config/filter/network/http_connection_manager/v2/http_connection_manager.proto.html?highlight=http_protocol_options

dohnto commented 6 years ago

You are correct. Thank you.