getodk / aggregate

ODK Aggregate is a Java server that stores, analyzes, and presents survey data collected using ODK Collect. Contribute and make the world a better place! ✨🗄✨
https://docs.opendatakit.org/aggregate-intro/
Other
74 stars 228 forks source link

[Docker Compose] Inifinite redirect loop #413

Open dosanjosfilho opened 5 years ago

dosanjosfilho commented 5 years ago

Software and hardware versions

Ubuntu Server 18.04, Aggregate v2.0.0

Problem description

My ODK Aggregate is working normally under my domain example.com:8080 and www.example.com:8080, but when trying to use nginx for redirect I go into an infinite loop.

Steps to reproduce the problem

I'm setting up the ODK Agregator on my server following the "ODK Aggregate - Build and run with Docker Compose", I have changed the security.server.checkHostnames to false. And in my nginx installation is configured with Let's Encrypt.

security.properties:

security.server.deviceAuthentication=digest
security.server.secureChannelType=REQUIRES_INSECURE_CHANNEL
security.server.channelType=REQUIRES_INSECURE_CHANNEL
security.server.forceHttpsLinks=false
security.server.hostname=
security.server.port=8080
security.server.securePort=8443
security.server.superUserUsername=administrator
security.server.realm.realmString=ODK Aggregate
security.server.checkHostnames=false

nginx config.: *I changed my domain to example.com

server {

    root /var/www/example.com/html;
    index index.html index.htm index.nginx-debian.html;

    server_name example.com www.example.com;

    if ($host = example.com) {
        return 301 https://www.$host$request_uri;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # ma$
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # $
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    location / {
        try_files $uri $uri/ =404;
    }

    rewrite ^/rstudio$ $scheme://$http_host/rstudio/ permanent; 

    location /rstudio/ {
      rewrite ^/rstudio/(.*)$ /$1 break;
      proxy_pass http://localhost:8787;
      proxy_redirect http://localhost:8787/ $scheme://$http_host/rstudio/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;
      proxy_read_timeout 20d;
    }   
    rewrite ^/aggregate$ $scheme://$http_host/aggregate/ permanent; 

    location /aggregate/ {
      rewrite ^/aggregate/(.*)$ /$1 break;
      proxy_pass http://localhost:8080;
      proxy_redirect http://localhost:8080/ $scheme://$http_host/aggregate/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;
      proxy_read_timeout 20d;
    }

}

server {

    if ($host = www.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    listen [::]:80;

    server_name example.com www.example.com;
    return 404; # managed by Certbot

}
ggalmazor commented 5 years ago

Hi, @DosAnjosFilho!

Until we can verify there's a bug to be fixed, support questions are better asked in the Support Forum. Please create a new post with the information you've detailed here. I'd ask you expand on some things:

In any case, please, take into account that the Docker Compose stacks are not quite there yet. They're meant for experimental and development use. If you need to host Aggregate for production, you have better (and supported) Cloud-Config stack alternatives with full SSL and domain support.

dosanjosfilho commented 5 years ago

Hi, @DosAnjosFilho!

Until we can verify there's a bug to be fixed, support questions are better asked in the Support Forum. Please create a new post with the information you've detailed here. I'd ask you expand on some things:

  • Can you double check the conf files you've attached? In the issue description, you mention that you've configured the checkHostnames param to false, but the config you're attaching doesn't match that.
  • Can you describe your network environment a little bit more and how are you launching the Docker Compose stack?

In any case, please, take into account that the Docker Compose stacks are not quite there yet. They're meant for experimental and development use. If you need to host Aggregate for production, you have better (and supported) Cloud-Config stack alternatives with full SSL and domain support.

Hello, @ggalmazor

chrismclarke commented 4 years ago

Hi @DosAnjosFilho , did you fix this in the end? I recently tried setting up aggregate via docker-compose with an nginx reverse-proxy and letsencrypt for https and all worked fine. Let me know if you want me to share any compose files