Code Monkey home page Code Monkey logo

Comments (3)

phlax avatar phlax commented on June 24, 2024

cc @rshriram @lizan @mattklein123 @alyssawilk

from envoy.

marc-barry avatar marc-barry commented on June 24, 2024

I tried adding an HTTP Lua filter to see if I could modify the ":authority" and it appears to have worked. We really don't want to introduce Lua into our system but this allowed me to test out an option if there is no native configuration way to do this with Envoy. If doing it with code is the only way then we'd much prefer to use the HTTP WASM filter as you can pass dynamic configuration into the filter and we prefer to write Go and compile to WASM. I'm still hoping there is a native way to do this without code.

Here's the code that simply always replaces the upstream port with 80 to see if it was possible. I didn't figure out how to pass dynamic port mappings to the script such as mentioned in the description of this issue.

-- Define the Lua filter
function envoy_on_request(request_handle)
    -- Retrieve the destination address and port
    local authority_header = request_handle:headers():get(":authority")
    local destination_address, existing_port = authority_header:match("^(.-):?(%d*)$")

    -- If there's an existing port, remove it
    if existing_port then
        authority_header = destination_address
    end

    local destination_port = "80" -- Change this to the desired upstream port

    -- Modify the destination port
    request_handle:headers():replace(":authority", authority_header .. ":" .. destination_port)
end

from envoy.

marc-barry avatar marc-barry commented on June 24, 2024

We decided to rewrite the Lua as Go code and output WASM and load it as a HTTP WASM filter which also accepts a configuration which is like the port_value which exists in the SNI dynamic forward proxy. This is the best solution that we could come up with at this time. We are hopeful we missed something within the Envoy configuration.

from envoy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.