Wiki source code of Setting up NginX

Version 1.4 by kuchumovn on 2009/12/19

Show last authors
1 {{warning}}Attention!
2
3 I'm not an experienced NginX user, and this configuration is highly experimental and using it is kinda subject to risk...
4
5 You likely won't need NginX if you have just a couple of hundred users browsing your wiki per moment...
6 At least that's what i've read on the, uh, Internets...
7 Again, I'm not even a system administrator, I'm just being kinda enthusiastic.{{/warning}}
8
9 I'm running //XWiki Enterprise// on //Glassfish 2// Application Server.
10 //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"//.
11 //Glassfish// is installed in ///user/local/glassfish/glassfish// folder.
12
13 I've configured my //NginX// as follows (///etc/nginx.conf//):
14
15 {{code}}
16 user www-data;
17 worker_processes 1;
18
19 events {
20
21 worker_connections 1024;
22
23 use epoll;
24 }
25
26 http {
27
28 include mime.types;
29 default_type application/octet-stream;
30
31 sendfile on;
32 tcp_nopush on;
33 tcp_nodelay on;
34
35 gzip on;
36
37 server {
38
39 listen 80;
40
41 server_name vostrets.ru;
42
43 # redirect all http://vostrets.ru/* requests to http://www.vostrets.ru/*
44 rewrite ^(.*) http://www.vostrets.ru$1 permanent;
45 }
46
47 server {
48
49 listen 80;
50
51 server_name www.vostrets.ru;
52
53 charset utf-8;
54
55 access_log /var/log/nginx_access.log;
56
57 # count skin images for static data, though they are in "bin" path
58 location ~* ^/xwiki/bin/skin/(.*)\.(jpg|jpeg|gif|png|ico)$ {
59
60 access_log off;
61
62 rewrite ^/xwiki/bin/skin/(.*)\.(jpg|jpeg|gif|png|ico) http://www.vostrets.ru/xwiki/$1.$2 permanent;
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 expires max;
74 }
75
76 # ... bla bla bla ...
77
78 # forward all http://vostrets.ru/xwiki/ requests to http://vostrets.ru:8080/xwiki/
79 location /xwiki/ {
80
81 proxy_pass http://localhost:8080;
82 proxy_set_header X-Real-IP $remote_addr;
83 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
84 proxy_set_header Host $http_host;
85
86 expires 0m;
87 }
88 }
89 }
90 {{/code}}

Get Connected