External IP directs to Tomcat9 page instead of XWiki

I created a redirect from our WAN IP > http://localhost:8080/xwiki/bin/view/Main/
primarily to test out XWiki from outside our LAN.

To my surprise this didn’t bring me to the XWiki site like I was hoping. Instead it brings me to a tomcat9 site saying -

"It works !

If you’re seeing this page via a web browser, it means you’ve setup Tomcat successfully. Congratulations!

This is the default Tomcat home page. It can be found on the local filesystem at: `/var/lib/tomcat9/webapps/ROOT/index.html"

I need it to get me to the XWiki login page. I created a redirect within the above index.html file but I can’t find where to redirect it to to get me to the main page of XWiki.

I’m trying to find out how I can either create a link within the above tomcat9 index.html file that brings me to the XWiki login page or any alternate way to accomplish the same thing. I need the above WAN IP to direct me to the XWiki login page.

I’ve found this Stack Overflow post that seems to describe what I want to do but it’s talking about files that aren’t there, like the web.xml file within ROOT. I’m trying to determine if performing these edits is the correct way to go or if there’s a more simple way to get this working.

Any and all help is appreciated!

For anyone else who runs into this issue this is a quick work around that I configured to gain outside access to XWiki -

First create a simple redirect within the main tomcat9 page that shows up when accessing [IP of machine]:8080. Note that anything trailing after the 8080 is truncated and doesn’t route within a forwarding rule so you will need to specify it directly. An example is that I created the forwarding to take the External WAN IP and to forward it to -

http://[IP of XWiki machine]:8080/xwiki/bin/view/Main

But all it would do is truncate it to -

http://[IP of XWiki machine/localhost]:8080

Which is the tomcat9 homepage and is the reason for why I ran into the issue describe above.

To work around this issue do the following -

Go to -

/var/lib/tomcat9/webapps/ROOT

and backup the index.html file with the following command -

sudo cp index.html index.html.bak

Edit the index.html file by using vim or nemo or whatever editor you have installed.

Within the [info here] code block type in the following to create a redirect link within the index.html page -

XWiki

Note that this also can be done with an index.jsp file too by following the directions from my OP above in the “Stack Overflow” link.

Once you add this line of code you are telling the link to go from it’s original page (http://[IP of Machine]:8080) and drill down further to the XWiki login page located at /xwiki/bin/view/Main.

I wish I could get the link to go directly to the XWiki login page and will update this post when I finally figure it out. Regardless this is a quick work around to be able to gain login access to the wiki from outside and to test XWiki on a mobile device.

This worked for me but I also performed the following tweaks to ensure it knew where to go -

Edit the xwiki.cfg file to specify the domain of your wiki. Create a copy of this file before making any edits. Navigate to the following path -

/etc/xwiki/

And copy the xwiki.cfg file found in this folder using the following command -

sudo cp xwiki.cfg xwiki.cfg.bak

After the file has been backed up open it in any terminal text editor such as vim or nemo. I used nemo so I performed the following command -

sudo nemo xwiki.cfg

Scroll down until you see the section under “URLs”. Within this section you will see commented out lines like the following -

xwiki.home=http://www.mydomain.com

etc. with another one similar to this. Add the following line to open your database/domain to the internet -

xwiki.home=http://[IP of machine]:8080/xwiki/bin/view/Main

Ofc. your wiki or sub wiki’s may have their own domain in which case something like http://xwiki.[IP of machine]:8080 should be edited accordingly.

Hope all of this helps!

Protip: if you want an html page to redirect to your wiki and you are only using tomcat, the following index.html file will do the trick:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Wiki</title>
<meta http-equiv="refresh" content="0; url=/xwiki/bin/view/Main/" />
</head>

<body>
<h1>Wiki</h1>
<p>redirecting to the <a href="/xwiki/bin/view/Main/">wiki</a></p>

</body>
</html>

The <meta http-equiv=“refresh” content=“0; url=/xwiki/bin/view/Main/”… line will cause the browser to automatically redirect to the correct location for you. If the browsers doesn’t honour the redirect, or it’s too slow, then there is a link.

Really though, what you should do is to have apache act as the front end to tomcat, and then have apache rewrite the urls and handle domain mapping directly. It’s much easier and cleaner than trying to do it with tomcat.