Hide last authors
Vincent Massol 5.2 1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 = Set up =
6
Manuel Smeria 2.5 7 {{warning}}
Vincent Massol 5.1 8 * This configuration has been contributed by an XWiki user and needs to be verified.
Manuel Smeria 2.5 9 * You likely won't need NginX if you have just a couple of hundred users browsing your wiki
10 {{/warning}}
kuchumovn 1.1 11
Vincent Massol 5.1 12 Example running XWiki on the Glassfish 2 Application Server:
Vincent Massol 6.1 13
Vincent Massol 5.1 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
Manuel Smeria 2.5 17 For more information you can consult the [[NginX manual>>http://wiki.nginx.org/Main]].
kuchumovn 1.1 18
Vincent Massol 5.1 19 NginX configuration example with ##<domain>## being ##vostrets.ru## (##/etc/nginx.conf##):
kuchumovn 1.1 20
21 {{code}}
22 user www-data;
Lukas Raska 3.1 23 worker_processes 2; # This should be equal to number of CPUs
kuchumovn 1.1 24
Lukas Raska 3.1 25 worker_rlimit_nofile 20000; # Max open file descriptors, increase if nginx is serving large amount of static data for many users
26
kuchumovn 2.2 27 events
28 {
Lukas Raska 3.1 29 worker_connections 1024; # number of max connections per worker (worker_connections * worker_processes = max connections)
kuchumovn 1.1 30 use epoll;
Lukas Raska 3.1 31 multi_accept on;
kuchumovn 1.1 32 }
33
Lukas Raska 3.1 34
kuchumovn 2.2 35 http
36 {
kuchumovn 1.1 37 include mime.types;
38 default_type application/octet-stream;
39
Lukas Raska 3.1 40 server_tokens off; # don't send nginx version to end users
41
kuchumovn 1.1 42 sendfile on;
43 tcp_nopush on;
44 tcp_nodelay on;
45
Lukas Raska 3.1 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
kuchumovn 2.2 53 server
54 {
55 listen 80;
kuchumovn 1.1 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
kuchumovn 2.2 63 server
64 {
kuchumovn 1.1 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
kuchumovn 2.2 74 location ~* ^/xwiki/bin/skin/(.*)\.(jpg|jpeg|gif|png|ico)$
75 {
kuchumovn 1.4 76 access_log off;
77
kuchumovn 2.2 78 rewrite ^/xwiki/bin/skin/(.*) /xwiki/$1 permanent;
kuchumovn 1.4 79
kuchumovn 2.1 80 expires max;
81 }
82
kuchumovn 1.1 83 # fetch all the data, which doesn't lie in "bin" path, as static data
kuchumovn 2.2 84 location ~* ^/xwiki(?!/bin/).+\.(jpg|jpeg|gif|png|ico|css|js)$
85 {
kuchumovn 1.1 86 access_log off;
kuchumovn 1.3 87
88 # ${root} is the path, where the static files lie (i.e. ${root}/xwiki/skins/toucan/logo.png)
kuchumovn 1.1 89 root /user/local/glassfish/glassfish/domains/default_domain/applications/j2ee-modules;
kuchumovn 2.2 90
kuchumovn 1.1 91 expires max;
92 }
93
kuchumovn 2.3 94 # forward all http://vostrets.ru/ requests to http://vostrets.ru:8080/
95 location /
kuchumovn 2.2 96 {
kuchumovn 1.1 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;
Lukas Raska 4.1 101 proxy_set_header X-Forwarded-Proto $scheme;
kuchumovn 1.1 102
kuchumovn 2.3 103 expires 0m;
kuchumovn 1.1 104 }
kuchumovn 2.2 105
106 # ...
kuchumovn 1.1 107 }
108 }
109 {{/code}}
Vincent Massol 5.1 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