Wiki source code of Configure NginX Server as a Proxy on a Windows OS
Last modified by Eleni Cojocariu-testing account on 2026/08/21 17:10
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | NginX forwards requests to the XWiki [[Servlet Container>>doc:documentation.xs.admin.installation.methods.install-xwiki-war.configure-servlet-container.WebHome]] on a Windows system, using the [[directives XWiki needs>>doc:documentation.xs.admin.installation.http-reverse-proxy.nginx-key-configurations.WebHome]]. Windows has no NginX package and no ##sites-available## directory, so the server is unpacked from an archive and everything is configured in the single ##conf\nginx.conf## file. | ||
| 2 | |||
| 3 | 1. Make sure your wiki is running and reachable locally, for example at {{code language="none"}}http://localhost:8080/xwiki{{/code}}. | ||
| 4 | 1. Download the Windows build of [[NginX>>https://nginx.org/en/download.html]]. | ||
| 5 | 1. Extract the archive to ##C:\nginx##. | ||
| 6 | 1. Replace the ##server## block that ##C:\nginx\conf\nginx.conf## already holds with the following content, inside the ##http## section of that file:((( | ||
| 7 | {{code language="nginx"}} | ||
| 8 | map $http_upgrade $connection_upgrade { | ||
| 9 | default upgrade; | ||
| 10 | "" ""; | ||
| 11 | } | ||
| 12 | |||
| 13 | server { | ||
| 14 | listen 80; | ||
| 15 | server_name localhost; | ||
| 16 | |||
| 17 | access_log logs/xwiki-access.log; | ||
| 18 | error_log logs/xwiki-error.log; | ||
| 19 | |||
| 20 | client_max_body_size 0; | ||
| 21 | |||
| 22 | location = / { | ||
| 23 | return 301 /xwiki/; | ||
| 24 | } | ||
| 25 | |||
| 26 | location /xwiki { | ||
| 27 | proxy_pass http://localhost:8080; | ||
| 28 | |||
| 29 | proxy_set_header Host $http_host; | ||
| 30 | proxy_set_header X-Real-IP $remote_addr; | ||
| 31 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| 32 | proxy_set_header X-Forwarded-Proto $scheme; | ||
| 33 | proxy_set_header X-Forwarded-Host $http_host; | ||
| 34 | proxy_set_header Forwarded ""; | ||
| 35 | |||
| 36 | proxy_http_version 1.1; | ||
| 37 | proxy_set_header Upgrade $http_upgrade; | ||
| 38 | proxy_set_header Connection $connection_upgrade; | ||
| 39 | |||
| 40 | proxy_redirect off; | ||
| 41 | } | ||
| 42 | } | ||
| 43 | {{/code}} | ||
| 44 | ))) | ||
| 45 | 1. Open a Command Prompt, go to the installation directory with {{code language="none"}}cd C:\nginx{{/code}}, and check the configuration: {{code language="none"}}nginx -t{{/code}}. | ||
| 46 | 1. Start NginX: {{code language="none"}}start nginx{{/code}}. After any later change to ##nginx.conf##, use {{code language="none"}}nginx -s reload{{/code}} instead. | ||
| 47 | 1. Open {{code language="none"}}http://localhost{{/code}} in a browser. NginX redirects to {{code language="none"}}http://localhost/xwiki/{{/code}} and the wiki loads through port ##80##, with no port number in the address. |