Mercurial > code > home > repos > light9
annotate bin/homepageConfig @ 1217:e703b3434dbd
websocket and web cleanup
Ignore-this: ac6bd0444bc03ee79ce71c4aa7740bc0
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Mon, 08 Jun 2015 02:08:25 +0000 |
parents | 0d295af23c4b |
children | 70f42f9d6e04 |
rev | line source |
---|---|
1215 | 1 #!bin/python |
2 from run_local import log | |
3 from rdflib import RDF, URIRef | |
4 from light9 import networking, showconfig | |
5 from light9.namespaces import L9 | |
6 | |
7 from light9.rdfdb.syncedgraph import SyncedGraph | |
8 from twisted.internet import reactor | |
9 | |
10 graph = SyncedGraph(networking.rdfdb.url, "homepageConfig") | |
11 | |
12 @graph.initiallySynced.addCallback | |
13 def printConfig(result): | |
14 with graph.currentState() as current: | |
15 netHome = current.value(showconfig.showUri(), L9['networking']) | |
16 for role, server in current.predicate_objects(netHome): | |
17 if not server.startswith('http'): | |
18 continue | |
19 path = current.value(role, L9['urlPath']) | |
20 server = server.rstrip('/') | |
1217
e703b3434dbd
websocket and web cleanup
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
21 print """ |
e703b3434dbd
websocket and web cleanup
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
22 location /%(path)s { |
e703b3434dbd
websocket and web cleanup
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
23 |
e703b3434dbd
websocket and web cleanup
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
24 # for websocket |
e703b3434dbd
websocket and web cleanup
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
25 proxy_http_version 1.1; |
e703b3434dbd
websocket and web cleanup
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
26 proxy_set_header Upgrade $http_upgrade; |
e703b3434dbd
websocket and web cleanup
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
27 proxy_set_header Connection "upgrade"; |
e703b3434dbd
websocket and web cleanup
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
28 proxy_set_header Host $host; |
e703b3434dbd
websocket and web cleanup
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
29 |
e703b3434dbd
websocket and web cleanup
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
30 proxy_pass %(server)s; |
e703b3434dbd
websocket and web cleanup
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
31 rewrite /[^/]+/(.*) /$1 break; |
e703b3434dbd
websocket and web cleanup
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
32 }""" % vars() |
1215 | 33 |
34 reactor.stop() | |
35 | |
36 reactor.run() |