Coder Social home page Coder Social logo

Comments (3)

datvm avatar datvm commented on May 23, 2024

Please check the pull request. Usage:

            services.AddProxy(configureOptions: options =>
            {
                options.RewriteResponseLocationHeader = true;
            });

I still haven't understood your Unit Test yet so I will need your help on this. I have tested it with https://httpstat.us/301.

from proxykit.

damianh avatar damianh commented on May 23, 2024

It appears the upstream host is not aware of or using the x-forwarded headers. If it uses those headers, it would generate the correct absolute URL in the location header. Is this not the case?

from proxykit.

damianh avatar damianh commented on May 23, 2024

@datvm I've added a test #79 that ensures the location header is correct. If your upstream host is not generating the correct URLs then it is not configured to use X-Forwarded-* headers correctly. Please see the relevant section in the documentation.

Finally, if you really want or need to to do location header rewrites do it in your proxy code. Something like...

    app.RunProxy(async context =>
    {
        var response = await context
            .ForwardTo("http://localhost:" + port + "/")
            .AddXForwardedHeaders()
            .Send();
        if (response.Headers.Location != null)
        {
            response.Headers.Location = <rewrite here>;
        }
        return response;
    }));

... which could be wrapped in an extension method.

As such, I won't be accepting your proposed change.

from proxykit.

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.