Otree using subdirectory with nginx reverse proxy

303 views
Skip to first unread message

Jürgen Fleiß

unread,
Oct 18, 2021, 5:25:07 AM10/18/21
to oTree help & discussion
Hi everyone,

currently setting up oTree on an Ubuntu Server at our University and trying to find the best way to implement multiple users at the same time.

The documentation recommends using different ports for different users (https://otree.readthedocs.io/en/latest/server/ubuntu.html?highlight=nginx#sharing-a-server-with-other-otree-users). 

However, thats not possible for me as I only have ports 80 and 443 open to the outside world. Is it possible to use otree with different subdirectories for different users with an nginx reverse proxy?

Best,
Jürgen

Max R. P. Grossmann

unread,
Oct 18, 2021, 5:37:19 AM10/18/21
to Jürgen Fleiß, oTree help & discussion
Hi Jürgen,

Nope, that is not possible at the moment.

If you can't use different ports, you could use different subdomains (if your university allows that). The best case would be a wildcard subdomain and nginx redirecting each subdomain to a different (internal) port on which oTree is running.

Best,

Max

Alex D

unread,
Oct 18, 2021, 5:49:38 AM10/18/21
to oTree help & discussion
Hi Jürgen,
you might want to check out Dokku - a PasS open source heroku alternative. I have a Dokku instance, where we host our multiple experiments and each experiment gets its own dokku container. Quite convenient and fast. We then run otree experiments on subdomains as Max suggested and use lets encrypt for certificates, as getting a wildcard certificate from all our subdomains from our universities provider was not possible. Thus we only need port 443 running on https (and 80).

The added advantage of Dokku (or another Docker solutions) over one single instance of using containers for individual experiments is, that you can have multiple versions of otree/python/ other packages installed without problems if different experiments require different versions of packages. 

Best,
Alex

BonnEconLab

unread,
Oct 19, 2021, 5:48:35 AM10/19/21
to oTree help & discussion
Dear Jürgen et al.,

I initially followed the same approach that Jürgen mentioned: having a single server with multiple user accounts. Obviously, I had to address the same problem: having to re-route the ports 80 and 443 to the user-specific oTree ports (additionally, also re-routing HTTP to HTTPS so that all traffic is encrypted). The consequence was that no experiments could be run simultaneously, and when a different user wanted to run their oTree experiment, I had to change the nginx configuration file.

We soon set up a second server and then a third server and a fourth … with several users ending up having accounts on multiple servers, because when they wanted to run their most recent experiment, the server that they had initially used was occupied by someone else.

As a consequence, I recently switched to simply setting up one server per user. All these servers are virtual machines, so cloning an existing server to set up a new one is a matter of minutes (of course, I delete all the data that has been collected on the cloned server). Fortunately, our IT department says that I will run out of IP addresses before I hit any hardware limitations regarding disk space, CPU performance, RAM available … :-D

It would be interesting, though, to hear more from Alex about their Dokku-based implementation! What are the advantages, Alex, over having a different server (virtual machine) per user?

One Dokku-based solution is oTree Manager. Unfortunately, it is has turned into abandonware …

> Sub-domain hosting and wildcard SSL certificated proved difficult in university IT systems. Reverse proxying subpaths (example.com/otree1) to container instances appears to be impossible at this time due to some hard-coded oTree url routing.

Best,

Holger

Jürgen Fleiß

unread,
Oct 20, 2021, 10:32:50 AM10/20/21
to oTree help & discussion
Hi everyone,

thanks for the pointers and suggestions, I will look into it.

Best,
Jürgen
Reply all
Reply to author
Forward
0 new messages