I have built an application with Araneida and it rocks.
My problem: When I install a handler, I also give a host name
like this:
(defparameter *autotest-web-url* (make-url :scheme "http" :host "lark.bg.axxessit.no" :port 80))
(defparameter *listener* (make-instance 'threaded-http-listener :default-hostname "lark.bg.axxessit.no" :port 8000))
(install-handler (http-listener-handler *listener*) (make-instance 'show-test-handler) (merge-url *autotest-web-url* "/show-test") nil)
(Yes, I did a trick with netfilter/iptables to forward port 80 so I can run Araneida under a normal user. But the problem would surface anyway)
If my browser sends a different Host: -header, Araneida does not find a suitable handler. This happens if I use http://localhost/... or the short http://lark/... , and also when i use local forwarding via ssh from another machine (http://localhost:2080/...) Currently I install another handler for this (ahh, just saw that I can use the same handler and install it twice (thanks for letting me write this...))
Anyway, is there a better way? Can I specify a set of names, or just let Araneida ignore the hostname and port?
Perhaps you could register multiple listener translations for your webapp. When you set *listener*, the :translations keyword takes a list of translations. Each element of the :translations list is itself a list of 2 strings, the first element being the outside-visible URL and the second string being the URL as your lisp code sees it. Here is a barebones example where I translate a port 80 outside adress to a port 3000 inside address:
(setf *listener* make-instance #+araneida-uses-threads 'threaded-reverse-proxy-listener #-araneida-uses-threads 'serve-event-reverse-proxy-listener :translations `(("http://www.woodriverjewelry.com/" "http://www.woodriverjewelry.com:3000/") ("http://localhost/" "http://www.woodriverjewelry.com:3000/")) :address #(127 0 0 1) :port 3000)
In this example, www.woodriverjewelry.com resolves locally via my own DNS server. If I had no DNS server, I might just as easily have used localhost as the inside address.
You could easily have more than one outside address map to the same inside address. You could have localhost be one of your outside addresses, for example. In this way, your lisp code would always see the same inside address, while araneida would translate any number of outside addresses for you.
This moves the URL mapping out of your code and into your config. The above example is a simplification of my code. For the full deal, see:
http://static.woodriverjewelry.com/webapp-loader.lisp
Notice my listener :address is 127.0.0.1. I use pound as my front-end proxy. Araneida is not exposed to the internet. It listens only to the loopback interface. This is recommended, as araneida is not nearly as hardened, battle-worn and scrutinized as pound or apache. Between pound and apache, I pick pound for secureness. It is far more finicky about malformed requests.
If you use a reverse proxy, you will have to make your araneida webapp the "default" for all requests that do not match a specific rule. Here's my pound.cfg. Notice that apache is the catch-all in my config; you would reverse the roles, amd make araneida the catch-all:
User "nobody" Group "nobody" LogLevel 3 Alive 30 ListenHTTP Address 70.168.39.139 Port 80 End
ListenHTTP Address 192.168.1.1 Port 80 End
ListenHTTP Address localhost Port 80 End
Service HeadRequire "Host:.*www.woodriverjewelry.com.*" BackEnd Address localhost Port 3000 End Session Type BASIC TTL 300 End End
Service HeadRequire "Host:.*www.wrlug.org.*" BackEnd Address localhost Port 3000 End Session Type BASIC TTL 300 End End
Service # Catch All BackEnd Address localhost Port 81 End Session Type BASIC TTL 300 End End
Carlos Konstanski
On Wed, 20 Sep 2006, Johan Ur Riise wrote:
Date: Wed, 20 Sep 2006 02:14:13 +0200 From: Johan Ur Riise johan@riise-data.no To: araneida-devel@common-lisp.net Subject: [araneida-devel] host header
I have built an application with Araneida and it rocks.
My problem: When I install a handler, I also give a host name
like this:
(defparameter *autotest-web-url* (make-url :scheme "http" :host "lark.bg.axxessit.no" :port 80))
(defparameter *listener* (make-instance 'threaded-http-listener :default-hostname "lark.bg.axxessit.no" :port 8000))
(install-handler (http-listener-handler *listener*) (make-instance 'show-test-handler) (merge-url *autotest-web-url* "/show-test") nil)
(Yes, I did a trick with netfilter/iptables to forward port 80 so I can run Araneida under a normal user. But the problem would surface anyway)
If my browser sends a different Host: -header, Araneida does not find a suitable handler. This happens if I use http://localhost/... or the short http://lark/... , and also when i use local forwarding via ssh from another machine (http://localhost:2080/...) Currently I install another handler for this (ahh, just saw that I can use the same handler and install it twice (thanks for letting me write this...))
Anyway, is there a better way? Can I specify a set of names, or just let Araneida ignore the hostname and port?
-- Hilsen Johan Ur Riise _______________________________________________ araneida-devel mailing list araneida-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/araneida-devel
araneida-devel@common-lisp.net