aboutsummaryrefslogtreecommitdiffstats
path: root/webstats/readme.org
blob: a72067369aeb76f7bbff53083e12511a99741592 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#+title: Track website visit statistics

* Setup lighttpd
On the config file append the proxy to the running lisp server
#+begin_src conf
server.modules += ( "mod_proxy" )

$HTTP["url"] =~ "^/stats/" {
  proxy.server = ("" =>
                   ( "hunchentoot" =>
                     ( "host" => "127.0.0.1",
                       "port" => 4252 )
                   )
                 )
  proxy.header = (
    "map-urlpath" => ( "/stats" => "" )
  )

}
#+end_src

Setting up CORS
#+begin_src conf
server.modules += ( "mod_setenv" )
  # For CORS we need to allow all origins
  setenv.add-response-header += (
    "Access-Control-Allow-Origin" => "*",
    "Access-Control-Allow-Credentials" => "true"
  )
  # For CORS OPTIONS requests we should say which methods are allowed
  $HTTP["request-method"] == "OPTIONS" {
    setenv.add-response-header += (
      "Access-Control-Allow-Methods" => "GET, POST, OPTIONS",
      "Access-Control-Expose-Headers" => "Content-Range, Date, Etag, Cache-Control, Last-Modified",
      "Access-Control-Allow-Headers" => "Content-Type, Origin, Accept, Range, Cache-Control",
      "Access-Control-Max-Age" => "600",
      "Timing-Allow-Origin" => "*"
    )
  }
#+end_src