OpenProject Installed using Docker - Problem with Nginx: Redireted too many times

594 views Asked by At

I have hit a wall trying to fix a problem with my openProject installation. I installed it following the instructions in this guide. Then, I added an A record for my public IP and subdomain using world4you. I also created SSL certificates with Let's Encrypt:

mkdir /var/www/certbot/openproject.invert.at
certbot certonly --webroot -w /var/www/certbot/openproject.invert.at -d openproject.invert.at

Then I created and modified a file named /etc/nginx/sites-enabled/openproject.eeg_invert.de as follows:

server {
    listen 80;
    listen [::]:80;
    listen 443 ssl;
    listen [::]:443 ssl;

    # ssl_certificate /etc/letsencrypt/live/openproject.eeg_invert.de/fullchain.pem;
    # ssl_certificate_key /etc/letsencrypt/live/openproject.eeg_invert.de/privkey.pem;

    access_log /var/log/nginx/access_openproject.eeg_invert.de.log;
    error_log /var/log/nginx/error_openproject.eeg_invert.de.log;

    server_name openproject.eeg_invert.de;
    if ($http_user_agent ~* ".*SemrushBot.*") {return 403;}

    location '/.well-known/acme-challenge' {
        root /var/www/certbot/openproject.eeg_invert.de;
    }

    location / {
        if ($scheme = http) {
            return 301 https://$server_name$request_uri;
        }
        proxy_set_header     X-Script-Name /;
        proxy_set_header     X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header     X-Remote-User $remote_user;
        proxy_set_header     Host $http_host;
        # proxy_redirect http:// https://;
        proxy_pass http://localhost:8080;

    }
}

I reloaded nginx and everything worked just fine. However, I updated this application using cd /docker/openproject/compose && docker-compose pull && docker-compose up -d and reloaded nginx but now I am getting this message on chrome:

This page isn’t working openproject.eeg_invert.de redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS

I backed up all relevant docker volumes and the entire project folder (where the compose file is located) before updating. I am in no way an expert in IT so what I did so far is to run docker-compose down after updating. Then I restored the project folder and ran docker-compose up -d.

The problem is that now I am still getting the same error. I looked at the nginx error log files, but nothing comes up. I tried disabling some of the options at random from the nginx files to see if that changes something but it is always the same.

I have hit a wall now and I would very much appreciate your help! Thanks in advance for any suggestions or ideas you may have.

2

There are 2 answers

1
Abhishek S On

Did you try clearing cookies in your browser? There are many reasons why this issue can occur:

  • Issues with the browser's cache/cookies. The browser may be caching faulty data that leads to the redirection error.
  • The browser extensions. Sometimes a browser extension can cause a redirection error.
  • The website's URL. A misconfiguration in URL settings can cause the redirection error.
  • WordPress cache. The website cache could be causing a redirect loop.
  • SSL certificate. A misconfigured security protocol (SSL certificate) can cause a redirect loop.
  • Third-party services and plugins. A faulty WordPress plugin could be causing the redirection loop.
  • The site's .htaccess file. A user-level configuration file WordPress uses to rewrite URLs to the index.php file. The website URL is defined as a value in the database.
0
stftnk On

For anyone looking for an answer to this, try to put OPENPROJECT_HTTPS to true explicitly and inject it in the docker command like this:

docker run -d -p 8080:80 --name openproject \
  -e OPENPROJECT_HTTPS=true \
  -e OPENPROJECT_HOST__NAME=your.hostname \
  -e OPENPROJECT_SECRET_KEY_BASE=your-secret \
  -v /var/lib/openproject/pgdata:/var/openproject/pgdata \
  -v /var/lib/openproject/assets:/var/openproject/assets \
  openproject/community:13

And also you should add the following line into your NGINX location / server block:

proxy_set_header X-Forwarded-Proto $scheme;

This will solve CSRF token mismatch problem.