Ok simply wow. After searching the internet a lot. there is so much contradictory information but the solution for XWiki to bring Realtime WYSIWYG alive over nginx seems top be way to easy.
Some nginx documentation and configuration snipets tells that Websockets need to run on another port, but as you stated the websockets runs on the same port.
When running both on the same port however some documentation then tells that websockets needs to run on another path than the http stuff (examples http stuff on servername.domain.com:8080/xwiki/ and web socket stuff on servername.domain.com:8080/websocketstuff/) to switch the proxy forwarding. Which is not something that brought me closer to a solution.
For Apache on the other hand it seems to be more easy to understand as it can be defined for ws:// and wss:// seperated form http:// and http://
However for Nginx with xwiki + Realtime Editing I found the super simple solution here by coincidence: How to use Nginx as a Reverse proxy for HTTPS and WSS - Self Signed Certificates and Trusted Certificates (linkedin.com)
Put these few lines for additional headers below the proxy forwarding headers and then websocket is also handled successfully…
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
I am quite new to nginx and tomcat and hosting Xwiki so take this all with not only a grain of salt but rather a spoon of salt. But for me this 3 lines made it work.
So the complete simple port 80 (without SSL) configuration to run XWIKI with Realtime WYSIWYG on nginx is that:
server {
listen 80;
# REPLACE THIS WITH YOUR SERVERNAME AND DOMAIN AND TLD
server_name servername.domain.com,
# Normally root should not be accessed, however, root should not serve files that might compromise the security of your server.
root /var/www/html;
# Configuration to avoid Request Entity too large error 413
client_max_body_size 0;
location / {
# All "root" requests will have /xwiki appended AND redirected to mydomain.com
rewrite ^ $scheme://$server_name/xwiki$request_uri? permanent;
}
location ^~ /xwiki {
# If path starts with /xwiki - then redirect to backend: XWiki application in Tomcat
# Read more about proxy_pass: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
I’ll configure SSL later and give an update if the simple fix still applies, but right now I don’t have any doubts about it.