And edited ServerName and filled it with our domain information
Modules mod_proxy and proxy_a2enmod installed
But I wonder what is the best approach just serving domains to sub-wikis on one server, which is especially the thing I am trying to achieve.
Now we just set domain to main-xwiki and redirection from it’s homepage to sub-wiki’s homepage, which is not proper IMO (especially in multiple sub-wikis set to multiple domains).
Now we got exmpl.example.com targeted to main xwiki 220.127.116.11:8080/xwiki
And we did redirect from this main xwiki to subdomain’s homepage.
But we need to target exmpl.example.com to 18.104.22.168:8080/xwiki/wiki/subwiki to become it more expandable.
So the exmpl.example.com will be targeted to 22.214.171.124:8080/xwiki/wiki/subwiki with possibility to expand.
To make sure your vhosts are configured correctly, I dump an index.html file in the 3 DocumentRoot directories. The index.html file is a single line with only the text “<h1>[servername]</h1>” where [servername] is the domain name of the vhost. If I access http://servername/ and I get the right content back, then I know apache is configured properly.
Step 4: Configure tomcat/xwiki to use hostname based subwikis (reference here)
edit /etc/xwiki/xwiki.properties and change url.standard.multiwiki.isPathBased to false (url.standard.multiwiki.isPathBased=false)
edit /etc/xwiki/xwiki.cfg and change xwiki.virtual.usepath to 0 (xwiki.virtual.usepath=0)
The following urls won’t work correctly after doing step 4. You’ll get an ugly error message. You can intercept that call and redirect it to the correct server if you wish, but I wouldn’t worry about it too much.
configuring SSL is left as an exercise to the reader. I recommend using the “letsencrypt” software to manage the settings for you automatically with apache. You configure your http hosts and it will do the rest.
tomcat has three ways to support connections from apache; via
Forget 3, as it is an old method.
If you use 1 (it’s simple and is easier to debug problems between apache and tomcat), then I suggest you bind Tomcat only to 127.0.0.1 to make sure not to expose your tomcat instance to the world. I only bind Tomcat to a public ip when I am testing things out. In the above example, we’re using this method.
The mod_ajp connection is a binary protocol that is supposedly more efficient to allow tomcat and apache to communicate. You can find the details in the /etc/tomcat9/server.xml. Search for AJP. You can then configure apache to proxy to ajp://127.0.0.1:8009/xwiki instead of http://127.0.0.1:8080/xwiki/.
When you have that working, you can disable Tomcats http connector.
Finally, adding a new wiki should be as simple as creating a new subwiki, and creating a new apache vhost configuration file with the details updated for the new subwiki name.
If anyone with more experience in this matter has any suggestions, corrections or updates, they are most welcome to share them. I only just tested this out now and while it seems to work, I may have missed something important.
After some settings to Apache I am able to reach parent wiki and its subwikis like this as I was before.
I understand you are saying to set vhosts in Apache to every wiki or subwiki which is need to do like this. But I am just really confused how should I save, move, symlink or just copy subwiki into this folder:
My xwiki is installed using debian installation process (on official docs) and it is installed in: usr/lib/xwiki, usr/share/xwiki, etc/xwiki and var/lib/xwiki/data. And what is more I don’t understand how should I trace the subwiki in filesystem, when all I can trace is the whole xwiki farm.
This was just no problem.
If I would follow your example, will I be able to have other apps in Tomcat next to this XWIKI settings? Or do I have to have XWIKI on separate server? I know that I need to have only one XWIKI on server without using virutal server or docker solution.
I just need to have parent xwiki accessible with IP like 126.96.36.199:8080/xwiki and my subwiki in this wiki to have to be set to my domain like: 188.8.131.52:8080/xwiki/wiki/mysubwiki -> somepart.maindomainpart.com, that’s all. I have the Apache set (I hope correctly), setting the configuration of xwiki files is very possible. I just don’t understand that part with DocumentRoot. I have found some other guides or steps on the internet and I think it was not solved at all. How can I in most straight way connect my domain to my sub-xwiki?
You don’t have to have a different document root for every subwiki vhost.
The only reason I did this was to make sure that I could test my apache vhost installations to make sure they were configured properly. Once I knew it was configured properly, I could use the same DocumentRoot for all subwiki vhosts.
The choice to do that or not, is up to you. It’s not necessary and has no other affect on the xwiki installation as it is only an apache configuration.
I’m afraid I don’t understand what you mean. The more I think about it, the more I think the question doesn’t matter.
Yes. If you understand how to install additional servlets in Tomcat, then it’s very simple. However, that’s beyond the scope of this explanation.
Some people will say “don’t do it” and some people will say “it’s fine”. As long as your Tomcat JVM has enough memory and CPU, there shouldn’t be an issue.
If you look at those domains/urls, that’s exactly what you want, isn’t it? As long as you followed the previous steps, confirmed that everything works at each step, then you will have each subwiki served by their own subdomains (#2 and #3 in the quoted list above)
And if adding /xwiki to the url is still too much, then you can make a single DocumentRoot that is identical for all vhosts and added in the following index.html:
<meta http-equiv="refresh" content="0; url=/xwiki/bin/view/Main/" />
<p>redirecting to the <a href="/xwiki/bin/view/Main/">xwiki</a></p>
This will cause all the browsers automatically to redirect to the xwiki installation. Also, since the url doesn’t specify the domain but only path, then the same file will work for all the xwikis, as long as you have completed step 4 correctly. Thus your urls can be as simple as:
I am very thankful to you because of these explanation you are providing to my case. I don’t think this is “too complex” or just “too much”. I just don’t understand some steps because I am pure Tomcat beginner and I have worked only with Apache, PhP, MySQL and so on. And I don’t want to bother you more than needed.
So instead of this I should fill there the real location of war files of XWIKI?
To set domain to sub-wiki only I will follow only this, right? But I am anyway targeting xwiki parent on loopback but there is no target of actuall sub-wiki. That is why I asked you about the filesystem presence of sub-wiki:
But there is no other trace of actuall sub-wiki than in the: /var/www/subwiki1 of your text, which you said is only an example. So to transfer your example to my situation I need to know what instead of your example I should fill there. I am very sorry for being confused, but I just don’t get it.
After I have follwed the steps you made I just ended with: subdomain.maindomain.com = 184.108.40.206:8080/xwiki
which is the main wiki, not subwiki.
It might be easier if I logged into your server and configured it for you. Either that, or I send you the virual machine where everything is already configured.
The problem is your lack of experience. It’s like trying to run before you’ve even learned how to walk.
There are two ways you could run xwiki. You could serve it from Tomcat directly, or you could have Apache proxy the xwiki requests for Tomcat. The configuration I described is the last one because while Tomcat is a very good application server, it is not a good webserver.
So, all requests to xwiki/tomcat in my configuration are first handled by apache, and then only the xwiki requests are forwarded to Tomcat.
We use Apache to define our virtual hosts and subdomains because it’s easier than doing it in tomcat (I actually forget how to do that in tomcat, but that doesn’t matter). Once apache is configured properly, then the requests are proxied and sent to tomcat where, as long as tomcat is configured properly, it does the right thing and sends the requests to the appropriate wiki/subwikis.
In Tomcat, there is almost nothing to configure as almost everything is already configured for you.
The steps you listed that you do not understand are for the Apache configuration only. Apache doesn’t care about xwiki, or where the jar files are. It only needs to know what requests to send, and where to send those requests.
If you follow my steps listed above, and you test every link I ask you to test, then your configuration will work. I am not sure how I can make those instructions any simpler.
If you do anything difference from what I’ve listed, then I don’t know what will happen.
Thank you for more wide explanation of this issue. With all respect I think that I have already knew about this issue like it is. After I have done some number of Apache settings for PhP application I still have some deficit (probably) in Apache to Tomcat settings. Problem persisted in setting the Apache to Tomcat for sub-wiki as it itself where decent ambiguity is present as here as on the internet (in other forums). Everybody has been able to set it to parent wiki not to subwiki. Although I am immensely grateful for your time invested to me, but I still have to do testing and research for this issue. I think we just didn’t understood each other I need to set domain to subwiki where the domain has none text same with name of xwiki. It is more like: 123.asdf.com = 123.asdf.com/xwiki/wiki/jkljkl where “jkljkl” is name of subwiki. Do your settings actually work for particular subwiki? Or is it just working settings for Apache to Tomcat connections? I am deeply sorry, but this settings besides the “DocumentRoot” which you said is irrelevant does not wear any signs of particular subwiki aim, everything then is just set to /xwiki not /xwiki/wiki/jkljkl (example).
As I said, I am very grateful and I feel sorry for not solving this situation. I will try my best in upcoming days to solve this issue. I still think and there might be some kind of misunderstanding. I thank you for every advice you have gave to me so far.
Have a nice day.