Wiki source code of Set up NginX Proxy Server

Last modified by Raphaël Jakse on 2026/08/14 08:59

Show last authors
1 {{warning}}
2 WIP: create a separate tutorial for Windows OS.
3 {{/warning}}
4
5 To set up NginX proxy server:
6
7 1. Make sure your wiki is running and accessible locally, (e.g., at {{code language="none"}}http://localhost:8080/{{/code}}.
8 1. [[Install Nginx>>https://nginx.org/en/docs/install.html]].
9 1. Start the NginX service. For example in a Linux OS, {{code language="none"}}sudo systemctl start nginx{{/code}}, or in Windows {{code language="none"}}start nginx{{/code}}.(((
10 * You can test if it's running: {{code language="none"}}curl http://localhost{{/code}}. You should see the default NginX page.
11 )))
12 1. Create or edit the Nginx configuration file:(((
13 * Open (e.g., in Linux OS {{code language="none"}}sudo nano /etc/nginx/sites-available/xwiki{{/code}}, or in Windows {{code language="none"}}C:\nginx\conf\nginx.conf{{/code}} and replace or adapt with a clean version:(((
14 {{code language="nginx"}}
15 # Server
16 server{
17 listen 80;
18 server_name localhost;
19
20 # Logs
21 access_log /var/log/nginx/xwiki-access.log;
22 error_log /var/log/nginx/xwiki-error.log;
23
24 client_max_body_size 0;
25
26 # Reverse proxy to XWiki
27 location /xwiki {
28 proxy_pass http://localhost:8080/xwiki;
29
30 # Headers
31 proxy_set_header Host $host;
32 proxy_set_header X-Real-IP $remote_addr;
33 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
34 proxy_set_header X-Forwarded-Proto http;
35
36 # WebSocket
37 proxy_http_version 1.1;
38 proxy_set_header Upgrade $http_upgrade;
39 proxy_set_header Connection "upgrade";
40
41 proxy_redirect off;
42 }
43 # Redirect root -> xwiki
44 location = / {
45 return 301 /xwiki;
46 }
47 }
48 {{/code}}
49 )))
50 )))
51 1. Enable the site. For example in a Linux OS, {{code language="none"}}sudo ln -s /etc/nginx/sites-available/xwiki /etc/nginx/sites-enabled/{{/code}}, or in Windows add the server block directly inside ##nginx.conf##, inside the {{code language="none"}}http{}{{/code}} section.
52 1. Test config. For example in a Linux OS, {{code language="none"}}sudo nginx -t{{/code}}, or in Windows {{code language="none"}}nginx -t{{/code}}.
53 1. Restart Nginx, if the step above was successful. For example in a Linux OS,{{code language="none"}}sudo systemctl restart nginx{{/code}}, or in Windows {{code language="none"}}nginx -s reload{{/code}}.
54 1. Test in browser:(((
55 * Go to: {{code language="none"}}http://yourdomain.com{{/code}}, or locally: {{code language="none"}}http://localhost{{/code}}
56 )))
57 1. Test proxy behavior:(((
58 * Check headers: {{code language="none"}}curl -I http://localhost{{/code}}.
59 * Check logs. For example in a Linux OS,{{code language="none"}}tail -f /var/log/nginx/access.log{{/code}}, or in Windows {{code language="none"}}C:\nginx\logs\access.log{{/code}}
60 )))

Get Connected