How can I configure NGINX to fix the "No 'Authorization: Basic' header found" error

To resolve the “No ‘Authorization: Basic’ header found” error when using NGINX with Nextcloud, follow these configuration steps:

NGINX Configuration

  1. Edit your NGINX configuration file (usually located at /etc/nginx/sites-available/your_site.conf or similar).

  2. Add the following directives within the location block that handles your Nextcloud requests:

    location / {
        proxy_pass http://your_nextcloud_backend; # Replace with your backend server
        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_hide_header Upgrade; # This hides the Upgrade header
    }
    
  3. Ensure that you have the following headers set to pass the authorization information correctly:

    proxy_set_header Authorization $http_authorization;
    
  4. Add well-known redirects for CardDAV and CalDAV:

    location /.well-known/carddav {
        return 301 $scheme://$host/remote.php/dav;
    }
    
    location /.well-known/caldav {
        return 301 $scheme://$host/remote.php/dav;
    }
    
  5. Test your configuration to ensure there are no syntax errors:

    sudo nginx -t
    
  6. Reload NGINX to apply the changes:

    sudo systemctl reload nginx
    

Additional Considerations

  • If you are using Docker or a specific setup like Nginx Proxy Manager, ensure that any specific settings related to headers are also configured accordingly, such as client_max_body_size and proxy_request_buffering.

  • Some users have reported success by simply adding proxy_hide_header Upgrade; to their configuration, which can help with issues related to header stripping that might cause authentication problems.

By following these steps, you should be able to fix the authorization header issue and successfully log into your Nextcloud instance using the iOS app.