Configure nginx as reverse proxy

When researching how to properly wrap Xwiki in a professional environment (using SSL and routing from the root page of a web server) I came across this page in the documentation:

Setting up NginX (

It was not helpful, so I ended up with my own solution, using nginx and the following configuration file:

server {
  listen 80 default_server;
  server_name _;
  return 301 https://$host$request_uri;

server {
  listen 443 ssl http2 default_server;

  ssl_certificate /etc/ssl/private/certs/fullchain.pem;
  ssl_certificate_key /etc/ssl/private/certs/privkey.pem;

  server_name _;

  client_max_body_size 100M;

  access_log /var/log/nginx/xwiki-access.log;
  error_log /var/log/nginx/xwiki-error.log;

  location = / {
    return 301 https://$host/xwiki;

  location /xwiki {
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   Host      $host;
    proxy_http_version 1.1;
    proxy_set_header   Upgrade $http_upgrade;
    proxy_set_header   Connection 'upgrade';
    proxy_cache_bypass $http_upgrade;

This properly manages switching from http to https, redirecting requests to the root to the xwiki root, and handles the reverse proxy so port 8080 is hidden from the users.

1 Like

Thank you for sharing this! I’ve been fussing with this for days and your solution seems to have nailed it on my end.