Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 = Set up =
6
7 {{warning}}
8 * This configuration has been contributed by an XWiki user and needs to be verified.
9 * You likely won't need NginX if you have just a couple of hundred users browsing your wiki
10 {{/warning}}
11
12 Example running XWiki on the Glassfish 2 Application Server:
13
14 * NginX listens on ##<domain>:80## and redirects HTTP queries to ##<domain>:8080## and thus NginX is referred to as "frontend" and Glassfish as "backend".
15 * Glassfish is installed in the ##/user/local/glassfish/glassfish## folder.
16
17 For more information you can consult the [[NginX manual>>http://wiki.nginx.org/Main]].
18
19 NginX configuration example with ##<domain>## being ##vostrets.ru## (##/etc/nginx.conf##):
20
21 {{code}}
22 user www-data;
23 worker_processes 2; # This should be equal to number of CPUs
24
25 worker_rlimit_nofile 20000; # Max open file descriptors, increase if nginx is serving large amount of static data for many users
26
27 events
28 {
29 worker_connections 1024; # number of max connections per worker (worker_connections * worker_processes = max connections)
30 use epoll;
31 multi_accept on;
32 }
33
34
35 http
36 {
37 include mime.types;
38 default_type application/octet-stream;
39
40 server_tokens off; # don't send nginx version to end users
41
42 sendfile on;
43 tcp_nopush on;
44 tcp_nodelay on;
45
46 gzip on;
47 gzip_comp_level 4; # increase for better compression (values 1 to 9, 1 = fastest, 9 = slowest/best compression)
48 gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; # compress multiple mime types
49 gzip_disable "msie6"; # disable gzip for IE<=6
50 gzip_vary on; # send Vary: Accept-Encoding header
51 gzip_proxied any; # enable compression for proxied requests
52
53 server
54 {
55 listen 80;
56
57 server_name vostrets.ru;
58
59 # redirect all http://vostrets.ru/* requests to http://www.vostrets.ru/*
60 rewrite ^(.*) http://www.vostrets.ru$1 permanent;
61 }
62
63 server
64 {
65 listen 80;
66
67 server_name www.vostrets.ru;
68
69 charset utf-8;
70
71 access_log /var/log/nginx_access.log;
72
73 # count skin images for static data, though they are in "bin" path
74 location ~* ^/xwiki/bin/skin/(.*)\.(jpg|jpeg|gif|png|ico)$
75 {
76 access_log off;
77
78 rewrite ^/xwiki/bin/skin/(.*) /xwiki/$1 permanent;
79
80 expires max;
81 }
82
83 # fetch all the data, which doesn't lie in "bin" path, as static data
84 location ~* ^/xwiki(?!/bin/).+\.(jpg|jpeg|gif|png|ico|css|js)$
85 {
86 access_log off;
87
88 # ${root} is the path, where the static files lie (i.e. ${root}/xwiki/skins/toucan/logo.png)
89 root /user/local/glassfish/glassfish/domains/default_domain/applications/j2ee-modules;
90
91 expires max;
92 }
93
94 # forward all http://vostrets.ru/ requests to http://vostrets.ru:8080/
95 location /
96 {
97 proxy_pass http://localhost:8080;
98 proxy_set_header X-Real-IP $remote_addr;
99 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
100 proxy_set_header Host $http_host;
101 proxy_set_header X-Forwarded-Proto $scheme;
102
103 expires 0m;
104 }
105
106 # ...
107 }
108 }
109 {{/code}}
110
111 = Troubleshooting =
112
113 == Request Entity Too Large ==
114
115 If you find the following message in your logs: {{code}}Failed to load resource: the server responded with a status of 413 (Request Entity Too Large){{/code}} then you might want to try to [[increase the request body size>>http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size]] since it seems nginx does not allow request bodies larger than 1MB by default.

Get Connected