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

Login redirect issue #2765

Closed
samlar opened this issue May 24, 2021 · 4 comments
Closed

Login redirect issue #2765

samlar opened this issue May 24, 2021 · 4 comments

Comments

@samlar
Copy link

samlar commented May 24, 2021

Describe the bug
This bug has been fixed in previous version but has recurred, old case: #1048

After logging, a redirection occurs to https://test.se/BookStack/BookStack. Normally is https://test.se/BookStack. And an error message shows up saying Sorry, The page you were looking for could not be found. Still login is successful and there are no other issues. Im using Subdirectory Setup and more about my configuration down below.

Temporary workaround that works for me now is, this is set in apache virtual conf:
Redirect temp /BookStack/BookStack https://test.se/BookStack

Steps To Reproduce
See above.

Expected behavior
No redirection should occur.

Screenshots
N/A

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): v21.04.5
  • PHP Version: PHP 7.3.27-1
  • Hosting Method (Nginx/Apache/Docker): Apache/2.4.38

Additional context
Apache configuration:

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName www.test.se
        ServerAlias test.se

        ServerAdmin test@test.se
        DocumentRoot /var/www/test

        # BookStack Configuration
        Alias "/BookStack" "/var/www/BookStack/public"

        Redirect temp /BookStack/BookStack https://test.se/BookStack

       <Directory "/var/www/BookStack/public">
       Options FollowSymlinks
       AllowOverride None
       Require all granted

       RewriteEngine On
       # Redirect Trailing Slashes If Not A Folder...
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^(.*)/$ /$1 [L,R=301]

       # Handle Front Controller...
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^ index.php [L]
       </Directory>

      <Directory "/var/www/BookStack">
      AllowOverride None
      Require all denied
      </Directory>
      # End BookStack Configuration

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/test.se/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/test.se/privkey.pem
</VirtualHost>
</IfModule>

.env configuration APP_URL=https://test.se/BookStack

@samuelstj
Copy link

Same problem here. Does anyone have a workaround?

@ssddanbrown
Copy link
Member

ssddanbrown commented Oct 29, 2021

Some notes from testing just now:

  • Redirect seems to go to the right location when system is public (Where we manually store the uri).
  • Redirect seems to gain duplicated prefix on same instance but when non-public.

From further testing:

  • Removal of custom Request does solve the issue for sub-path setups but that then breaks existing sub-path proxy style setups from my testing.

@ssddanbrown
Copy link
Member

ssddanbrown commented Apr 2, 2022

Another report in #3361.
Have tested and can reproduce in an apache-based environment after Ubuntu install script usage.
Have assigned this to the next feature release for another attempt at addressing.

Notes from testing

These urls are generated using:

  • Base http host
  • A base URL
  • The path

https://github.com/symfony/http-foundation/blob/c816b26f03b6902dba79b352c84a17f53d815f0d/Request.php#L1008

We're overriding the initial one, via getSchemeAndHttpHost, but including the additional base path for sub-path setups.
In such issue scenarios, The $this->getBaseUrl() also returns this sub-path element (At least on Apache, It's detection is complex and likely non-matching in all environments, hence our forced base http host originally).
We likely need to force override both of these elements, so that the custom path is forced as the baseURL and we alter our base http host to just be the host element.


PR open in #3364

ssddanbrown added a commit that referenced this issue Apr 2, 2022
This updates the custom Request handler to provide only the scheme and
host on the `getSchemeAndHttpHost` call, instead of providing the whole
APP_URL value, while adding an override to the 'getBaseUrl' to use the
APP_URL content instead of the guessed/detected Symfony value.

Untested apart from simple local setup.

Related to #2765
@ssddanbrown
Copy link
Member

I've now merged in #3364 which will be part of our next feature release, so I'll therefore close this off.
Note, this kind of thing is very environment dependant. If you're coming to this with problems in the future, after the v22.04, please open a new support request issue so we can get details of your environment.

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

No branches or pull requests

3 participants