Show last authors
1 I used lighttpd, but I assume it can be done with other webservers too. This is the configuration I used in the lighttpd config (note that my xwiki folder has been moved to ##/usr/share/jetty/webapps/root## (no 'xwiki' at all)):
2
3 {{code language="none"}}
4 $HTTP["host"] =~ "^www\.domain\.com$" {
5 # ensure all requests for .gwtrpc files go through to java server
6 # we can put this rule first as a higher priority, which java couldn't do
7 $HTTP["url"] =~ "\.gwtrpc$" {
8 proxy.server = ( "" => (( "host" => "127.0.0.1", "port" => 8080 )))
9 }
10 # otherwise, we can handle the static resources
11 else $HTTP["url"] =~ "^/resources/" {
12 alias.url += ( "/resources" => "/usr/share/jetty/webapps/root/resources" )
13 }
14 # otherwise, we can handle the static resources
15 else $HTTP["url"] =~ "^/skins/" {
16 alias.url += ( "/skins" => "/usr/share/jetty/webapps/root/skins" )
17 }
18 # and here is the primary server
19 else $HTTP["host"] =~ "^www\.domain\.com$" {
20 proxy.server = ( "" => (( "host" => "127.0.0.1", "port" => 8080 )))
21 }
22 }
23 # redirect anything.domain.com to www.domain.com
24 else $HTTP["host"] =~ "\.domain\.com$" {
25 url.redirect = ( "^/(.*)" => "http://www.domain.com/$1" )
26 server.name = "www.domain.com"
27 }
28 # redirect domain.com to www.domain.com
29 else $HTTP["host"] =~ "domain\.com$" {
30 url.redirect = ( "^/(.*)" => "http://www.domain.com/$1" )
31 server.name = "www.domain.com"
32 }
33 {{/code}}
34
35 So lighttpd will serve any static content unless it has ##.gwtrpc## on the end of the URL.
36
37 If you use Nginx as a web-server, just add three more locations and set ##root## to them. By ##try_files## Nginx checks static content presence and if doesn't exist, redirect it to the Tomcat (we expect dynamic content in this case, including all ##*.gwtrpc## requests).
38
39 {{code}}
40 location /skins/ {
41 root /var/lib/tomcat7/webapps/ROOT;
42 }
43
44 location /resources/ {
45 try_files $uri $uri/ @fallback;
46 root /var/lib/tomcat7/webapps/ROOT;
47 }
48
49 location @fallback {
50 proxy_pass http://localhost:8080;
51 }
52 {{/code}}
53
54 In the example above XWiki installed as ROOT application in Tomcat. Change path to your XWiki application accordingly.
55
56 Then in ##web.xml##, I changed the ##gwtrpc## mapping to:
57
58 {{code language="xml"}}
59 <servlet-mapping>
60 <servlet-name>gwtrpc</servlet-name>
61 <url-pattern>/resources/*</url-pattern>
62 <url-pattern>/skins/*</url-pattern>
63 </servlet-mapping>
64 {{/code}}
65
66 Since we are using a url-pattern of ##/path/##, it will be specific enough to be a higher priority than the ##/## pattern we'll use next. And since the only thing that will come through via resources or skins will be ##gwtrpc##, then we can be sure it's ok. Note that only ##resources## is required, but I did both anyway.
67
68 Now, as described above, add a rule to catch everything else and redirect it to your XWiki servlet:
69
70 {{code language="xml"}}
71 <servlet-mapping>
72 <servlet-name>action</servlet-name>
73 <url-pattern>/*</url-pattern>
74 </servlet-mapping>
75 {{/code}}

Get Connected