Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No redirect after log in #1234

Closed
rmoreRojoli opened this issue Sep 2, 2020 · 8 comments
Closed

No redirect after log in #1234

rmoreRojoli opened this issue Sep 2, 2020 · 8 comments

Comments

@rmoreRojoli
Copy link

After filling in the login details and pushing log in, it will get stuck in a "logging in" state, network tab shows a cancelled request to /login
On the server side the nextcloud container reports a POST request and nothing else:
nextcloud | 172.20.0.1 - - [02/Sep/2020:17:31:41 +0000] "POST /login HTTP/1.1" 303 1130 "-" "browser agent list"

After a page refresh on the /login will take successfully to the logged in page of /apps/files/

The container is running behind Traefik v2 reverse proxy

Relevant docker compose section:

  pg-nextcloud:
    image: postgres
    container_name: pg-nextcloud
    restart: always
    networks:
      - nextcloud
    environment:
      - POSTGRES_PASSWORD=xxx
      - POSTGRES_USER=xxx
      - POSTGRES_DB=nextcloud
  nextcloud:
    image: nextcloud:19
    container_name: nextcloud
    restart: always
    depends_on:
      - pg-nextcloud
    networks:
      - nextcloud
      - traefik
    environment:
      POSTGRES_DB: 'nextcloud'
      POSTGRES_USER: 'xxx'
      POSTGRES_PASSWORD: 'xxx'
      POSTGRES_HOST: 'pg-nextcloud'
      NEXTCLOUD_ADMIN_USER: 'xxx'
      NEXTCLOUD_ADMIN_PASSWORD: 'xxx'
      NEXTCLOUD_TRUSTED_DOMAINS: 'example.com'
      TRUSTED_PROXIES: '172.0.0.0/8'
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=traefik"
      - "traefik.http.routers.nextcloud.entrypoints=https"
      - "traefik.http.routers.nextcloud.rule=Host(`example.com`)"
      - "traefik.http.routers.nextcloud.middlewares=sec-header@file,nextcloud-redirectregex"
      - "traefik.http.routers.nextcloud.tls.certResolver=letsencrypt"
      - "traefik.http.middlewares.nextcloud-redirectregex.redirectRegex.permanent=true"
      - "traefik.http.middlewares.nextcloud-redirectregex.redirectRegex.regex=https://(.*)/.well-known/(card|cal)dav"
      - "traefik.http.middlewares.nextcloud-redirectregex.redirectRegex.replacement=https://$${1}/remote.php/dav/"

Relevant traefik dynamic config:

http:
  middlewares:
    redirect-to-https:
      redirectScheme:
        scheme: https
    sec-header:
      headers:
        forceSTSHeader: true
        stsIncludeSubdomains: true
        stsSeconds: 31536000
        sslRedirect: true
        sslForceHost: true
        customResponseHeaders:
          Strict-Transport-Security: "max-age=63072000"

tls:
  options:
    default:
      minVersion: VersionTLS12
      cipherSuites:
        - TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
        - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
        - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
        - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
        - TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305
        - TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305

OS: Centos 8
latest docker and docker compose

@bdube
Copy link

bdube commented Sep 12, 2020

I'm also using Traefik v2 and had the same issue: login is succesful but the browser does not redirect anywhere. In my browser's console, I could see the browser was preventing a form action to a http resource from a page loaded by https. This was only in my browser's console log; there was no error to see in server logs.

The solution for me was to add OVERWRITEHOST=example.com and OVERWRITEPROTOCOL=https environment variables to the nextcloud section of docker-compose.yml and start over with a clean volume so that nextcloud would configure itself with these variables.

The environment variables end up in nextcloud's config.php as 'overwritehost' and 'overwriteprotocol', but when I tried to add these values to config.php without starting over, I would get 500 internal server errors.

@rmoreRojoli
Copy link
Author

These two additions solved the issue, Thank you!

@hrehfeld
Copy link

hrehfeld commented Nov 15, 2020

docker exec -u www-data -i nextcloud php occ config:system:set overwriteprotocol --value https
docker exec -u www-data -i nextcloud php occ config:system:set overwritehost --value $mydomain

worked for me with without resetting the volume.

@hrehfeld
Copy link

Can somebody explain why this is necessary? Can this be fixed in the reverse-proxy settings? (I'm using caddy.)

@erdoukki
Copy link

erdoukki commented Oct 14, 2021

Still locked in the login loop !

@Emporea
Copy link

Emporea commented Nov 3, 2021

I am also locked in login loop.

NC: 22.2
docker-compose

@ilovefreesw
Copy link

OVERWRITEHOST=example.com and OVERWRITEPROTOCOL=https

After adding these at the end of the docker compose file, It worked for me thanks.

@ariyaee1367
Copy link

I'm also using Traefik v2 and had the same issue: login is succesful but the browser does not redirect anywhere. In my browser's console, I could see the browser was preventing a form action to a http resource from a page loaded by https. This was only in my browser's console log; there was no error to see in server logs.

The solution for me was to add OVERWRITEHOST=example.com and OVERWRITEPROTOCOL=https environment variables to the nextcloud section of docker-compose.yml and start over with a clean volume so that nextcloud would configure itself with these variables.

The environment variables end up in nextcloud's config.php as 'overwritehost' and 'overwriteprotocol', but when I tried to add these values to config.php without starting over, I would get 500 internal server errors.

I dot this and resolve my issue , thanks for yuur explain my friend .
i added this env on the my docker compose and resolve the issue :
- OVERWRITEHOST=my domain
- OVERWRITEPROTOCOL=https

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants