We are running nginx as a reverse proxy that forwards requests to a Clojure application running Compojure, a library that wraps around Jetty and provides our application with the ability to service web requests.
We currently capture logs generated by both nginx and the Clojure application (via log4j to syslog). We are unable, however, to match an entry in the nginx log to an entry in the syslog output of the Clojure application.
We need to figure out a way to modify the request sent upstream to the Clojure app to include some kind of ID. This could be an integer, UUID, whatever.
Do you have any suggestions as to how best to accomplish this?
Thanks for your help!
Compojure is written on ring and ring has middleware :)
you would write a middleware called with-uuid that adds the UUID to the request map on the way in and to the reply on the way out.
Of course the best approach would be an nginx module, duplicating the functionality of apache's mod_unique_id.
There doesn't seem to be one yet. Here's a patch that wants to graduate to a module someday.:
http://mailman.nginx.org/pipermail/nginx-devel/2011-June/001015.html
Related
I have a little Clojure app that uses http-kit to send some http post requests to a server. I want to route the https POST request through a proxy P, ie. I want the traffic to go like App->Proxy->Server.
(This is because the target host X restricts access based on IP)
Is this possible?
Also the App runs on an ubuntu server, are there maybe system-level configurations possible to make http-kit use a proxy server? I prefer other processes to be unaffected though.
http-kit is supposed to follow the standard method of configuring proxies in Java:
-Dhttp.proxyHost=proxyhostURL \
-Dhttp.proxyPort=proxyPortNumber \
-Dhttp.proxyUser=someUserName \
-Dhttp.proxyPassword=somePassword
which you can set in your lein profile or in the application server if you are using one.
http-clj now support proxy: https://github.com/dakrone/clj-http#proxies
For http-kit, according to the author's reply in this issue, the answer is NO.
But the good news is fewer weeks before it support basic HTTP proxy ( commit a207537 on http-kit ).
After all, it seems there is no way to set up a system wide proxy for JVM applications.
I learn about being asynchronous when i write code with twisted, but i wonder now how do common web servers process thing asynchronously. As a case of this below:
apache get a client request from A, and there maybe some operations block the main process. If apache doesn't do some tricks here, then at the just time another client B send
a request , and obviously client B will get no response. Right? I guess, every client request will be processed in a dependent process/thread?
And django is a web framework, the question is whether django has the logic about "not blocking", or the work is handled totally by web servers.
There are no tricks here, really. Apache simply spins up multiple processes and/or threads (depending on how it is configured), and a request is routed to the next available one.
The logic is exclusively in the web server.
I have a Soap based web services running in websphere 8. Since we have he trace.log, which have the Webservices request and response XML. I am trying to log it to a different file apart from trace.log.
To be very precise, If my service is HelloWorldService. I would like to log the SOAP requests in service_helloworld.log. I have defined the appenders and loggers in log 4j already. But I am looking into a way where I could configure websphere to redirect the webservices traces to that file.
I still could write a interceptor, but I am trying it in websphere configs. Please help
I don't know if you still have that problem... But I had the same one and I just fix it implementing a GenericHandler that interceps the request/response.
Take a look:
http://www.ibm.com/developerworks/websphere/library/techarticles/0511_phung-lu/0511_phung-lu.html
Im new in C++.
I need to listen HTTP requests.
Please advice me some good tutorials or examples
Thanks
update:
Platform: Windows
Language: C++
I will explain more clearly what i need
when user clicks row on this page: http://ucp-anticheat.org/monitor.html applications is automatically starts on client machine.
I want to make same thing.
I think on client side is service which listens http requests and if url starts with steam:// service automatically runs application...
Do i need to listen http requests?
What is best solution for my problem?
You can listen to http requests through a web server like mongoose , which can be easily used in C++ http://code.google.com/p/mongoose/ , and here is a good example of using mongoose web server http://code.google.com/p/mongoose/source/browse/examples/hello.c
I m not sure what you mean 'client side', if you are meaning Browser as your client, you can't control nothing outside your browser. If you want to control a machine, you need your client machine to run your exe, that has the code to act based on your server instructions.
You should create a simple server program, create a SOCKET listening on default http, https etc, ports. Usually we do it inside a loop (at each one you make a read).
Now... would be easer if you specified if you are on Unix like OS or Windows, but from now on you can google it. Like sys/socket.h or try "man 7 socket" on almost all linux (at least the ones I know).
If you want to sniff something you can google some specific apps around web.
If i get your question right, you want to be able to launch an application when someone clicks a link with a custom protocol, like steam:// or telnet://. You are looking for an Protocol Handler.
A simple way to register such an application is using the ftype program, as described here.
I'd like to restrict access to my web service to registered clients. The first thing I thought of was to mimic that of AWS which, in a nutshell, issues clients a non-secret and secret key pair, and requires clients to prove knowledge of the secret key by using a cryptographic function of some of the HTTP request data and the secret key, then specifying the output of the crypto function in a request header. AWS does the same and checks that the expected signature matches what the client has specified. The secret is not transmitted, blah blah. This is pretty typical and not that interesting albeit useful.
http://mws.amazon.com/docs/devGuide/Signatures.html
http://chrisroos.co.uk/blog/2009-01-31-implementing-version-2-of-the-amazon-aws-http-request-signature-in-ruby
My preferred web server for web services is nginx. I'd like to start requiring similar request signatures in certain services. It makes sense to me to create an nginx module that handles request signature validation before ever sending the request to an upstream process (my web service instance(s)).
Do you know of such a nginx module? Do you know of a different one that I can base my work off of?
There's a decent nginx module writing guide here:
http://www.evanmiller.org/nginx-modules-guide.html
Please note that I'm not asking "how do I write a nginx module?" I'm simply trying to avoid reinventing the wheel.
Thanks!
If I'm understanding correctly, you could simply check for custom headers with an if($http_{yourheader}){} and validate that against a backend such as memcached, or proxy to a fastcgi script, or even use an embedded perl script (although this will be slow and could block).
AFAIK there aren't any specific standard or third-party modules that do this, but a combination of them could provide a suitable solution (eg; $http_{header} + redis backend, for instance).
Is there a particular reason you're not looking to use custom SSL certs? They would seem an adequate solution for restricting access with added security.