Wiki source code of Setting up NginX

Version 2.5 by Manuel Smeria on 2012/12/18

Show last authors
1 {{warning}}
2 * This configuration is highly experimental and using it may be risky
3 * You likely won't need NginX if you have just a couple of hundred users browsing your wiki
4 {{/warning}}
5
6 I'm running XWiki Enterprise on the Glassfish 2 Application Server.
7 NginX listens on //vostrets.ru:80// and redirects HTTP queries to //vostrets.ru:8080// and thus NginX is referred to as "frontend" and Glassfish as "backend".
8 Glassfish is installed in the ///user/local/glassfish/glassfish// folder.
9
10 For more information you can consult the [[NginX manual>>http://wiki.nginx.org/Main]].
11
12 I've configured my NginX as follows (**///etc/nginx.conf//**):
13
14 {{code}}
15 user www-data;
16 worker_processes 1;
17
18 events
19 {
20 worker_connections 1024;
21
22 use epoll;
23 }
24
25 http
26 {
27 include mime.types;
28 default_type application/octet-stream;
29
30 sendfile on;
31 tcp_nopush on;
32 tcp_nodelay on;
33
34 gzip on;
35
36 server
37 {
38 listen 80;
39
40 server_name vostrets.ru;
41
42 # redirect all http://vostrets.ru/* requests to http://www.vostrets.ru/*
43 rewrite ^(.*) http://www.vostrets.ru$1 permanent;
44 }
45
46 server
47 {
48 listen 80;
49
50 server_name www.vostrets.ru;
51
52 charset utf-8;
53
54 access_log /var/log/nginx_access.log;
55
56 # count skin images for static data, though they are in "bin" path
57 location ~* ^/xwiki/bin/skin/(.*)\.(jpg|jpeg|gif|png|ico)$
58 {
59 access_log off;
60
61 rewrite ^/xwiki/bin/skin/(.*) /xwiki/$1 permanent;
62
63 expires max;
64 }
65
66 # fetch all the data, which doesn't lie in "bin" path, as static data
67 location ~* ^/xwiki(?!/bin/).+\.(jpg|jpeg|gif|png|ico|css|js)$
68 {
69 access_log off;
70
71 # ${root} is the path, where the static files lie (i.e. ${root}/xwiki/skins/toucan/logo.png)
72 root /user/local/glassfish/glassfish/domains/default_domain/applications/j2ee-modules;
73
74 expires max;
75 }
76
77 # forward all http://vostrets.ru/ requests to http://vostrets.ru:8080/
78 location /
79 {
80 proxy_pass http://localhost:8080;
81 proxy_set_header X-Real-IP $remote_addr;
82 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
83 proxy_set_header Host $http_host;
84
85 expires 0m;
86 }
87
88 # ...
89 }
90 }
91 {{/code}}

Get Connected