DHIS2 and NGINX configuration

Hello community,

Am working on the deployment of dhis2 on a cloud server and am using docker, so i want to have nginx so that can act as a single request point that forwards request to dhis2 service but i have been facing error of redirecting because dhis2 redirects, so how can i handle this errors, i have tried many troubleshoot like setting server.base.url in dhis.conf:" DHIS2 configuration file

Database connection

connection.dialect = org.hibernate.dialect.PostgreSQLDialect

connection.driver_class = org.postgresql.Driver

connection.url = jdbc:postgresql://dhis2db:5432/dhis2

connection.username = ****

connection.password = ****

Server settings

server.base.url = http://localhost/dhis2

System settings

system.session.timeout = 3600

system.monitoring.provider = prometheus

system.sql.init = false

system.startup.failure.is.fatal = false

File store configuration

filestore.provider = filesystem

filestore.container = files", nginx default.conf:" # DHIS2 configuration
location /dhis2/ {
proxy_pass http://dhis2/;
proxy_redirect off;

    # DHIS2 specific timeouts
    proxy_read_timeout 600;
    
    # Additional DHIS2 headers
    proxy_set_header Host $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 $scheme;
    proxy_set_header Connection "upgrade";
    proxy_set_header Upgrade $http_upgrade;
    proxy_http_version 1.1;
    
    # Cache configuration for static content
    location ~* ^/dhis2/.*\.(js|css|png|jpg|jpeg|gif|ico)$ {
        proxy_pass http://dhis2;
        expires 24h;
        add_header Cache-Control "public, no-transform";
    }
}" but none of this troubleshoot has worked out

Hi

What’s this proxy_pass setting configured? Are you sure this one is correct?

Thanks!

Hi @mugisha_alain
I would have a look at the resources here

There you will find some Ansible scripts to help you get a DHIS2 server setup. We usually would not recommend using Docker for production, although we know that people do use it. The advantage with these tools are they are supported by the core DHIS2 team and are in use in the field.

Regarding your setup though I agree that the proxy_pass does not look correct.

Best regards,
Jason

2 Likes