Nginx Reverse Proxy - Infinite Redirect

You should see two buttons. “Copy” and “Open” . Until you don’t, it means that KPI cannot talk with Enketo Express. It must be related to your double proxy configuration.

I cannot test it soon but if I do, I let you know.

1 Like

Actually - this is without the double proxy. I’ve put Kobo behind a ELB just to eliminate that as a possibility for now. Sorry - I should have mentioned that.

Did you run the setup after again ?

Yep I ran the run.py. I did not remove the old instances/app directories though

Ok, I’ve made a test on my own and every works as expected.
I’ve created a proxy with NGINX hosted on the same EC2 instance.

Browser -> 443 - > ELB -> 80 -> NGINX Proxy -> 8080 -> Kobo NGINX.

The NGINX proxy is latest version (1.19) of NGINX in docker container.
I changed nothing except the default.conf
This is the NGINX Proxy configuration

server {
    listen 80;
    server_name $hostname;
    server_tokens off;

    # Allow 100M upload like KoBo NGINX
    client_max_body_size 100M;

    location / {
        proxy_pass  http://172.17.0.1:8080;  # 172.17.0.0.1 is the docker interface (`ifconfig docker0`)
        proxy_set_header    Host                $http_host;
        proxy_set_header    X-Real-IP           $remote_addr;
        proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto   https;
    }
}

I used KoboInstall Version: 2.4.2 (build 2.020.24b)

This is a copy/paste of what options I chose (I kept related options):

Where do you want to install?
[/home/ubuntu/kobo-docker]:
Please confirm path [/home/ubuntu/kobo-docker]
        1) Yes
        2) No
[1]:
Do you want to see advanced options?
        1) Yes
        2) No
[1]:
What kind of installation do you need?
        1) On your workstation
        2) On a server
[2]:
... 
Do you want to use separate servers for frontend and backend?
        1) Yes
        2) No
[2]:
Do you want to use HTTPS?
        1) Yes
        2) No
[1]:
╔════════════════════════════════════════════════════════════════════╗
║ Please note that certificates must be installed on a reverse-proxy ║
║ or a load balancer.                                                ║
║ KoBoInstall can install one, if needed.                            ║
╚════════════════════════════════════════════════════════════════════╝
Auto-install HTTPS certificates with Let's Encrypt?
        1) Yes
        2) No - Use my own reserve-proxy/load-balancer
[2]:
Is your reverse-proxy/load-balancer installed on this server?
        1) Yes
        2) No
[1]:
Internal port used by reverse proxy?
[8080]:
...
Do you want to expose backend container ports (`PostgreSQL`, `MongoDB`, `redis`) ?
        1) Yes
        2) No
[2]:
...
Removing network kobomaintenance_kobo-maintenance-network
WARNING: Network kobomaintenance_kobo-maintenance-network not found.
Removing kobofe_kpi_1            ... done
Removing kobofe_nginx_1          ... done
Removing kobofe_kobocat_1        ... done
Removing kobofe_enketo_express_1 ... done
Removing network kobofe_kobo-fe-network
Network kobobe_kobo-be-network is external, skipping
Stopping kobobe_mongo_1       ... done
Stopping kobobe_redis_main_1  ... done
Stopping kobobe_postgres_1    ... done
Stopping kobobe_redis_cache_1 ... done
Removing kobobe_mongo_1       ... done
Removing kobobe_redis_main_1  ... done
Removing kobobe_postgres_1    ... done
Removing kobobe_redis_cache_1 ... done
Removing network kobobe_kobo-be-network
Launching environment
Creating network "kobobe_kobo-be-network" with driver "bridge"
Creating kobobe_redis_cache_1 ... done
Creating kobobe_postgres_1    ... done
Creating kobobe_mongo_1       ... done
Creating kobobe_redis_main_1  ... done
Waiting for PostgreSQL database to be up & running...
Creating network "kobofe_kobo-fe-network" with driver "bridge"
The PostgreSQL database is running!
Creating kobofe_enketo_express_1 ... done
Creating kobofe_kobocat_1        ... done
Creating kobofe_nginx_1          ... done
Creating kobofe_kpi_1            ... done
Waiting for environment to be ready. It can take a few minutes.
..
╔═════════════════════════════════╗
║ Ready                           ║
║ URL: https://kftest.xxx.xxx/    ║
║ User: super_admin               ║
║ Password: 1111111               ║
╚═════════════════════════════════╝
$> docker ps
CONTAINER ID        IMAGE                                            COMMAND                  CREATED             STATUS              PORTS                  NAMES
80c501a287c0        kobotoolbox/kpi:2.020.24b                        "/bin/bash -c 'exec …"   7 minutes ago       Up 7 minutes        8000/tcp               kobofe_kpi_1
5920f89a0a30        kobotoolbox/kobocat:2.020.24b                    "/sbin/my_init"          7 minutes ago       Up 7 minutes        8000/tcp               kobofe_kobocat_1
8a1e4a734e33        kobotoolbox/enketo-express-extra-widgets:2.3.5   "/bin/bash -c 'ENKET…"   7 minutes ago       Up 7 minutes        8005/tcp               kobofe_enketo_express_1
063b3fb9b41d        nginx:1.19                                       "/docker-entrypoint.…"   7 minutes ago       Up 7 minutes        0.0.0.0:8080->80/tcp   kobofe_nginx_1  # KoBo NGINX
5f4d8c7aa07b        postgis/postgis:9.5-2.5                          "docker-entrypoint.s…"   7 minutes ago       Up 7 minutes        5432/tcp               kobobe_postgres_1
3820539f1bf3        redis:3.2                                        "docker-entrypoint.s…"   7 minutes ago       Up 7 minutes        6379/tcp               kobobe_redis_main_1
2338d3f827c7        mongo:3.4                                        "docker-entrypoint.s…"   7 minutes ago       Up 7 minutes        27017/tcp              kobobe_mongo_1
1b7ac2a7b540        redis:3.2                                        "docker-entrypoint.s…"   7 minutes ago       Up 7 minutes        6379/tcp               kobobe_redis_cache_1
bce8e4fe1ba5        nginx:latest                                     "/docker-entrypoint.…"   2 hours ago         Up 2 hours          0.0.0.0:80->80/tcp     nginx_nginx_1  # NGINX Proxy

I can create projects, deploy to KC, submit data through Enketo. (Open button works)
Hope it helps.

3 Likes