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

Cookie dir on reverse proxy #365

Open
FanchTheSystem opened this issue Nov 28, 2015 · 1 comment
Open

Cookie dir on reverse proxy #365

FanchTheSystem opened this issue Nov 28, 2015 · 1 comment

Comments

@FanchTheSystem
Copy link

Hello !

I am using kriss feed with a reverse proxy.

So on the remote server kriss url is not the same as on the proxy one.

In fact I use http://kriss.mydomain.com with proxy to http://localhost:3456/kriss

In this configuration the variable $_SERVER["SCRIPT_NAME"] can't be used (as it is not the same url as exposed one)

In the function getUrl() of the index.php
There is a check of the a variable named 'BASE_URL'

public static function getUrl()
    {
        $base =  isset($GLOBALS['BASE_URL'])?$GLOBALS['BASE_URL']:'';
        if (!empty($base)) {
            return $base;
        }

So I have added at the beginning of the index.php file

$BASE_URL='http://kriss.mydomain.com/';

It work well expect for cookie, so I can't connect or install Kriss Feed...

It is because when kriss try to find the cookiedir it use the variable $_SERVER["SCRIPT_NAME"] without a way to bypass it.

So to make it work on my server I have added this check for each cookiedir definition (one in init() function and one for login form :

   $cookiedir =  isset($GLOBALS['BASE_DIR'])?$GLOBALS['BASE_DIR']:'';
        if (empty($cookiedir)) {
           if (dirname($_SERVER['SCRIPT_NAME'])!='/') {
              $cookiedir = dirname($_SERVER["SCRIPT_NAME"]).'/';
           }
        }

It use a new variable I have set to :

$BASE_DIR='/';

So here is the full diff for index.php :

29a30,31
> $BASE_URL='http://kriss.mydomain.com/';
> $BASE_DIR='/';
4976,4979c4978,4983
<         $cookiedir = '';
<         if (dirname($_SERVER['SCRIPT_NAME'])!='/') {
<             $cookiedir = dirname($_SERVER["SCRIPT_NAME"]).'/';
<         }

---
>         $cookiedir =  isset($GLOBALS['BASE_DIR'])?$GLOBALS['BASE_DIR']:'';
>         if (empty($cookiedir)) {
>            if (dirname($_SERVER['SCRIPT_NAME'])!='/') {
>               $cookiedir = dirname($_SERVER["SCRIPT_NAME"]).'/';
>            }
>   }
8536,8539c8540,8545
<             $cookiedir = '';
<             if (dirname($_SERVER['SCRIPT_NAME'])!='/') {
<                 $cookiedir = dirname($_SERVER["SCRIPT_NAME"]).'/';
<             }

---
>       $cookiedir =  isset($GLOBALS['BASE_DIR'])?$GLOBALS['BASE_DIR']:'';
>             if (empty($cookiedir)) {
>                if (dirname($_SERVER['SCRIPT_NAME'])!='/') {
>                   $cookiedir = dirname($_SERVER["SCRIPT_NAME"]).'/';
>                }
>       }
@tontof
Copy link
Owner

tontof commented Nov 28, 2015

Thanks for the feedback. That could effectively be very useful!
I think the modification can be added in code.

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

2 participants