Using XWiki Docker image with Reverse proxy

Hello,

I am installing XWiki as Docker image with Treafik revers proxy on front, with path prefix like http://mydomain.org/xwiki/ as base path of the wiki.
I used different solutions without success :

  • default docker image that have ROOT web app, and Treafik PathPrefixStrip=/xwiki/
  • modified docker image with /xwiki web app, and Treafik PathPrefix=/xwiki/
  • modified xwiki.cfg attributes (xwiki.home= http://my-domain.org/xwiki/, xwiki.webapppath=xwiki/)

In all of that cases, the access to http://my-domain.org/xwiki/ result in altered page that reference files at base path like : http://my-domain.org/bin/login/

What is the solution to have XWiki responding to prefixed path (i can’t use sub domain path).

Thank,

The docker image deploys XWiki as ROOT in the servlet container (tomcat). So the URL for XWiki is http://mydomain.org/ and not http://mydomain.org/.

So what you would want is the ability to configure the xwiki deploy path. This is https://jira.xwiki.org/browse/XDOCKER-74.

Originally I deployed XWiki as ROOT to make the URLs shorter and nicer but maybe it wasn’t a great idea after all (Especially since we could offer a Short URL solution with a configured url rewriter filter in web.xml).

So I guess your need for http://mydomain.org/ is because you want server other services using the generic http://mydomain.org/<servicename> URL, right?

Related issue: https://jira.xwiki.org/browse/XDOCKER-52

Huh, typo? Where is the difference between http://mydomain.org/ and http://mydomain.org/? is an “xwiki” missing at the end of the second URL?

And why is this thread in “News & Events” actually?

Indeed typo, I meant:

So the URL for XWiki is http://mydomain.org/ and not http://mydomain.org/xwiki

Thanks for noticing.

I’ve moved it to the right category. Thx

Hello,

I have solved my problem by building my own Docker image. I changed initial Dockerfile and some others startup files for deploy XWiki as webapps/xwiki. But when changing URL of XWiki, it is important to reinitialize XWiki storage volume and data base, and execute initial configuration wizard.

Remark : the initial configuration wizard is executed if file “.first_start_completed” do not exist inside web app dir. This represent a risk if Docker container is re-created (update, restart).

This is strange. I don’t see what could be impacted by a change of servlet context path.

Did you have some path stored in database or configuration files at first start ?

Hi, I’m also using docker with apache as a reverse proxy.

I didn’t wan’t to open a new topic so I’m using this one as my problem is related to the topics subject.

Problem without Port 8080:
When I go to my wiki with wiki.domainname.com and try to create a page with a template I get the message (Couldn’t save the document. Server not responding):

xwiki-reverse-teil1
xwiki-reverse-teil2

The page gets created but says that the page is not accessable after creating it.
When I refresh the hole wiki, the page is there, so no problem.

When I access the wiki with wiki.domain.com:8080 I got no problem at all.

Is it because of my Apache vHost Config, do I miss something and can someone tell me what ?

I’d like to share my experiences for a best practice guide in Docker Best Practice Guide, but for that I first need to fix the problems a have.

My Apache vHost Configuration:

<virtualhost *:80>
    ServerName wiki.domainname.com

RewriteEngine on
RewriteCond %{SERVER_NAME} =wiki.domainname.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</virtualhost>

<virtualhost *:443>
    ServerName wiki.domainname.com

    ProxyRequests Off

    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

    SSLCertificateFile /etc/letsencrypt/live/wiki.domainname.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/wiki.domainname.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</virtualhost>

PS:
My catalina log didn’t show anything useful reagrding to this issue in that time while creating the page.

Too many people are reporting reverse proxy setup issues for the docker images caused apparently by the fact that the servlet context path is set to ROOT. Originally I thought it was a good idea since users were very often asking for short urls but apparently it wasn’t such a great idea.

At this stage I see 2 options:

  1. Change the behavior and document it
  2. Keep the behavior of deploying as ROOT but add a docker run config parameter to deploy under the xwiki context.

WDYT?

Hi @vmassol ,

I think you are right.
Yesterday I tried like 3 Hours on different Proxy Configurations with no success.

Right now I think I’ll do the following:

  1. Try Number 2 (on your post). But for that I need to google a little bit because I’m not exactly sure how to add these config parameter.

  2. I think the best thing to do, is just to run it under the Tomcat Ports. No need for “portless” URL.
    Therefore I’ll try to do what @mq2195 says in Using Tomcat SSL.

But I have to look how I can implement it in my docker-compose instead of using the docker-run command.

For me and my company is it just important to use Secure SSL, so if that means the users have to add :8443 to their Browser URL, I’m fine with that :slight_smile:

PS:
When I did this under http, not https, everything worked fine.

Just with https I got the error, when I do “save and show”.

BUT, if I do “Preview” -> “Save and Show” I got no error at all and everything seems to work with SSL and reverse proxy.

My development tools are showing me 302 when just “Save and Show” like @rissany posted on Failed to save page :

xwiki-error-1

Note that this is fixed now as there’s an option to deploy under any context, see the CONTEXT_PATH options under https://github.com/xwiki-contrib/docker-xwiki#configuration-options

Hi, just wanted to tell you, that I successfully could set up SSL without the need to give the port.

Thanks a lot to this video how to setup xwiki:

And for this video how to do the reverse proxy:

The nginxproxymanager is gold !!! Even can do letsencrypt.

Awesome. Thanks for posting back.

Anything you could update on https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/NginX/ or https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/ to make it easier for the anyone else who faces your issues?

Thanks