Skip to content

Instantly share code, notes, and snippets.

@Brunomachadob
Last active May 26, 2021 17:20
Show Gist options
  • Save Brunomachadob/2398f0b3a2ecef11f06384761fbf24cc to your computer and use it in GitHub Desktop.
Save Brunomachadob/2398f0b3a2ecef11f06384761fbf24cc to your computer and use it in GitHub Desktop.
Proxy with query parameters

Without the right query param:

○ → curl -v localhost:80/mge?serviceName=SessionManagerSP
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> GET /mge?serviceName=SessionManagerSP HTTP/1.1
> Host: localhost
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< date: Wed, 26 May 2021 17:19:14 GMT
< server: envoy
< content-length: 0
< 
* Connection #0 to host localhost left intact
* Closing connection 0

With the right query param:

○ → curl -v localhost:80/mge?serviceName=SessionManagerSP.getCoreSessions
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> GET /mge?serviceName=SessionManagerSP.getCoreSessions HTTP/1.1
> Host: localhost
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< date: Wed, 26 May 2021 17:17:55 GMT
< content-type: application/json; charset=utf-8
< content-length: 489
< etag: W/"1e9-euzX3lIS/m+3qcfZ7BXUqtBk+DM"
< vary: Accept-Encoding
< set-cookie: sails.sid=s%3ARA4vd8CsUanLgI-fVZuYUj0doNx-I-Er.oLNI%2B59%2FUQfrg4ZI4srvjKEa0Do4IND5gCanBBSbt90; Path=/; HttpOnly
< x-envoy-upstream-service-time: 223
< server: envoy
< 
* Connection #0 to host localhost left intact
{"args":{"serviceName":"SessionManagerSP.getCoreSessions"},"headers":{"x-forwarded-proto":"http","x-forwarded-port":"80","host":"localhost","x-amzn-trace-id":"Root=1-60ae82c3-4da1a9122162019b3ec59e0f","user-agent":"curl/7.64.1","accept":"*/*","x-request-id":"f4630113-8d54-4c42-9b10-96300676a5dd","x-envoy-expected-rq-timeout-ms":"15000","x-envoy-original-path":"/mge?serviceName=SessionManagerSP.getCoreSessions"},"url":"http://localhost/get?serviceName=SessionManagerSP.getCoreSessions"}
version: '3.4'
services:
gateway:
image: envoyproxy/envoy:v1.18.3
volumes:
- ./envoy.yaml:/opt/envoy.yaml
expose:
- 80
ports:
- 80:80
dns:
- 172.17.0.1
- 8.8.8.8
entrypoint:
- sh
- -c
- /usr/local/bin/envoy -c /opt/envoy.yaml --log-format '[proxy] %L%m%d %T.%e %t envoy] [%t][%n]%v' --component-log-level http:trace,router:trace,filter:trace,connection:trace,conn_handler:trace
static_resources:
listeners:
- name: main
address:
socket_address:
address: 0.0.0.0
port_value: 80
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
codec_type: AUTO
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains:
- "*"
routes:
- match:
prefix: "/mge"
query_parameters:
- name: serviceName
string_match:
contains: SessionManagerSP.getCoreSessions
route:
cluster: get_core_sessions
prefix_rewrite: /get
http_filters:
- name: envoy.filters.http.router
typed_config: {}
clusters:
- name: get_core_sessions
connect_timeout: 0.25s
type: STRICT_DNS # static
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: get_core_sessions
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: postman-echo.com
port_value: 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment