title: Nextcloud applications can not login
body: <p>Two weeks ago I decided to learn how to setup an Ubuntu server in order to install Nextcloud. After  reading several articles I managed to install Nextcloud using snap and I configured it in order to listen the 5000 port. I had to do it because I want to install other web applications as well so I did not want nextcloud to reserve ports 80 and 443. It worked and I tested it with a web browser, my Android device and I also installed the windows desktop application in order to upload and synchronize my files.</p>
  
  <p>I had done the first step and I had a working Nextcloud server. The next step was to secure it using an SSL certificate by Let’s Encrypt. I spent several hours trying to understand how to setup certbot in order to generate SSL certificates and I used NGINX web server in order to redirect the requests from my servers 443 port to the 5000 port that nextcloud was listening. I used the following configuration file in order to setup my domain to redirect to 5000 port.</p>
  
  <pre><code>server {
          listen               *:80;
          server_name          cloud.computermagic.gr;
          return 301            https://$server_name$request_uri;
  }
  server {
          listen               *:443 ssl http2;
          server_name          cloud.computermagic.gr;
  
          ssl on;
          ssl_certificate      /etc/letsencrypt/live/cloud.computermagic.gr/fullchain.pem;
          ssl_certificate_key  /etc/letsencrypt/live/cloud.computermagic.gr/privkey.pem;
          ssl_stapling on;
          ssl_stapling_verify on;
  
          location / {
              add_header Front-End-Https      on;
              proxy_headers_hash_max_size     512;
              proxy_headers_hash_bucket_size  64;
              proxy_set_header                Host $host;
              proxy_set_header                X-Forwarded-Proto $scheme;
              proxy_set_header                X-Real-IP $remote_addr;
              proxy_set_header                X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_pass                      http://localhost:5000;
          }
  }
  </code></pre>
  
  <p>I tried the nextcloud server with chrome and everything was perfect. I had the server behind a domain working with an SSL certificate. Then I tried to use the android and windows applications but for some reason I was not able to login. </p>
  
  <p>The application opens, I type the server address and when I type username and password in order to allow the application to access my server, the loading icon spins for ever. It does not display an error message so that I can understand what is the problem and I am not an experienced linux user so that I will understand what is the problem. </p>
  
  <p>I suppose there is something wrong with the configuration file because without the redirect the server seems to work properly with all the applications that I tried.</p>
  
  <p>Can someone help me?</p>
  
  <p><strong>UPDATE</strong>
  I removed the permanent redirect and it works.</p>
  
  <pre><code>server {
          listen               *:80;
          server_name          cloud.computermagic.gr;
  #        return 301            https://$server_name$request_uri;
          location / {
              add_header Front-End-Https      on;
              proxy_headers_hash_max_size     512;
              proxy_headers_hash_bucket_size  64;
              proxy_set_header                Host $host;
              proxy_set_header                X-Forwarded-Proto $scheme;
              proxy_set_header                X-Real-IP $remote_addr;
              proxy_set_header                X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_pass                      http://localhost:5000;
          }
  }
  server {
          listen               *:443 ssl http2;
          server_name          cloud.computermagic.gr;
  
          ssl on;
          ssl_certificate      /etc/letsencrypt/live/cloud.computermagic.gr/fullchain.pem;
          ssl_certificate_key  /etc/letsencrypt/live/cloud.computermagic.gr/privkey.pem;
          ssl_stapling on;
          ssl_stapling_verify on;
  
          location / {
              add_header Front-End-Https      on;
              proxy_headers_hash_max_size     512;
              proxy_headers_hash_bucket_size  64;
              proxy_set_header                Host $host;
              proxy_set_header                X-Forwarded-Proto $scheme;
              proxy_set_header                X-Real-IP $remote_addr;
              proxy_set_header                X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_pass                      http://localhost:5000;
          }
  }
  </code></pre>
  
  <p>is it safe to leave it like this?</p>