GithubHelp home page GithubHelp logo

Comments (5)

ekubacki avatar ekubacki commented on May 12, 2024

I am seeing an issue that is similar but it's also happening in async mode as well. I am getting the following error from nginx:
Invalid URL prefix in "should_get_overwritten", client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost:8080"

It's as if the rewrite handler is never getting called which results in the variable never being rewritten. Please see below for a gist of my setup.

here is a gist from my nginx.conf

http {
... 
  server {
        ....
        set $destination "should_get_overwritten";
        location / {
           handler_type 'java';
           rewrite_handler_name 'my.handlers.ProxyHandler';
           proxy_pass $destination;
        }
       ...
  }
....
}

ProxyHandler gist:

public class ProxyHandler implements NginxJavaRingHandler {
    private static final String DESTINATION_HOST = "destination";
    private static final String URL = "http://google.com";

    @Override
    public Object[] invoke(Map<String, Object> request) {
        System.err.println("============= Inside invoke =============");
        String destinationHost = determineDestinationHost();
        NginxJavaRequest r = ((NginxJavaRequest)request);

        NginxClojureRT.setNGXVariable(r.nativeRequest(), DESTINATION_HOST, destinationHost);

        return PHRASE_DONE;
    }

    private String determineDestinationHost() { return URL; }
}

few notes from documentation inaccuracies:

  1. documentation calls it: handler_rewrite_name which i have sense fixed to be called rewrite_handler_name
  2. I have to cast the incoming request as a NginxJavaRequest to get the nativeRequest in the java handler. This is not documented in the example provided

Intentions of what I am trying to do:
I am trying to achieve setting up a dynamically programmable reverse proxy

from nginx-clojure.

xfeep avatar xfeep commented on May 12, 2024

@ekubacki thank you very much!
I'll correct the document and try your example soon.

from nginx-clojure.

xfeep avatar xfeep commented on May 12, 2024

@ekubacki this issue won't happend in default mode.
You example meets issue #45 , I have fixed it just now by commit 6afeda3. The document has been corrected too.
Thanks again!

from nginx-clojure.

ekubacki avatar ekubacki commented on May 12, 2024

Thank-you for the correction in documentation :)

from nginx-clojure.

xfeep avatar xfeep commented on May 12, 2024

close it and we release v0.2.6 now.

from nginx-clojure.

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.