Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Show "Jatos local" after configuration of Apache as a proxy

edited July 2022 in JATOS

Hi there,

I've deployed Jatos on an AWS server, with Apache2 as the reverse proxy and SSL encryption. Since it is actually a local installation (because the binding port is localhost:8080), the GUI for my https:/[our domain name]/jatos show "Jatos local" on top, as it is shown here (https://www.jatos.org/Deploy-to-a-server-installation.html ), which mentions that "A local JATOS installation has a black bar on top. A server installation has a light-grey bar."

When I generate links for a study, they are all like this

https://localhost:8080/publix/GI2kz1qlkio

If I replace localhost:8080 with [our domain name], I can open the correct study webpage, but I need to replace "localhost:8080" for all links generated if I want to send them to participants.

Since I use reverse proxy, I think it is supposed to be set as local. But is there a way to make it like a real server installation?


I'm using an AWS EC2 Debian 11 instance;

In the production.conf, the IP and port are set as:

play.server.http.address = "0.0.0.0"
play.server.http.port = 8080

After I start jatos, it shows

admin@myserver:~/jatos_linux_java$ JATOS uses local Java
Starting JATOS... started
To use JATOS type 127.0.0.1:8080 in your browser's address bar

In the /etc/apache2/sites-available/mysite.com.conf, I have:

 



Let me know if you know how to solve the problem or you need more info!

Thank you very much!😀

Sheng

Comments

  • krikri
    edited July 2022

    Hi Sheng,

    I just tried it with JATOS version 3.7.4 on my machine and it worked. I can't see any obvious problems in your config.

    My config is:

    $ /usr/sbin/apache2 -v
    Server version: Apache/2.4.52 (Ubuntu)
    Server built:  2022-06-14T12:30:21
    

    and

    $ cat /etc/apache2/apache2.conf
    
    <VirtualHost *:80>
      ServerName www.example.com
     
      # Redirect all unencrypted traffic to the respective HTTPS page
      Redirect "/" "https://www.example.com/"
    </VirtualHost>
    
    <VirtualHost *:443>
      ServerName www.example.com
    
      # Restrict access to JATOS GUI to local network
      #<Location "/jatos">
      #  Order deny,allow
      #  Deny from all
      #  Allow from 127.0.0.1 ::1
      #  Allow from localhost
      #  Allow from 192.168
      #</Location>
    
      # Needed for JATOS to get the correct host and protocol
      ProxyPreserveHost On
      RequestHeader set X-Forwarded-Proto "https"
      RequestHeader set X-Forwarded-Ssl "on"
     
      # Your certificate for encryption
      SSLEngine On
      SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
      SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
    
      # JATOS uses WebSockets for its batch and group channels
      RewriteEngine On
      RewriteCond %{HTTP:Upgrade} =websocket [NC]
      RewriteRule /(.*)           ws://localhost:9000/$1 [P,L]
      RewriteCond %{HTTP:Upgrade} !=websocket [NC]
      RewriteRule /(.*)           http://localhost:9000/$1 [P,L]
    
      # Proxy everything to the JATOS running on localhost on port 9000
      ProxyPass / http://localhost:9000/
      ProxyPassReverse / http://localhost:9000/
    </VirtualHost>
    

    And I didn't change anything in JATOS' production.conf. So JATOS port is the default 9000.

    Hope this helps.

    Best,

    Kristian

    `

  • Thank you Kristian!

    Maybe I can try on another AWS instance.

  • It is working now! It shows yellow icon on the top bar!

    Although I'm not 100% sure, I can share what I did for your reference.

    Some files were generated during my configuration of Apache in the directory /etc/apache2/sites-avaibable and /etc/apache2/sites-enabled, which include "mysite.com-le-ssl.conf". I removed that file in both directories and redo the

    sudo a2ensite mysite.com.conf
    

    Maybe this is the solution.

Sign In or Register to comment.