tontof / kriss_feed

A simple and smart (or stupid) feed reader
280 stars 54 forks source link

Add support for servers not deployed on port 80, but redirected to #241

Closed Riduidel closed 11 years ago

Riduidel commented 11 years ago

My server is deployed on my port 8080 then redirected to port 80 by my freebox.

There are as a consequence some links that want to redirect me to my.public.address:8080/krissfeeed/... which obviously don't work.

So far, I've observed that behaviour when saving config (whatever config part I save) and on one other part of krissfeed I forgot.

tontof commented 11 years ago

Do you know if the referer is sent by your browser ? I understand the problem but don't really know how to solve it...

Riduidel commented 11 years ago

Le Thu, 27 Jun 2013 18:16:13 +0200, tontof notifications@github.com a
écrit:

Do you know if the referer is sent by your browser ?

Well, in fact I use Opera, and don't know what is sent by it. How can i
check that ?

I understand the problem but don't really know how to solve it...

That's no good news :-/ Selfoss author adds to its config.php file a base_url parameter that
allows configurations like mine to work OK (and selfoss worked correctly)
(but i don't know if it can be of any help to you). Here is selfoss doc
for that parameter

base_url base url of the selfoss page; use this option if you use a ssl
proxy which changes the $_SERVER globals

tontof commented 11 years ago

Try to update with the new unstable version : https://raw.github.com/tontof/kriss_feed/master/src/index.php and modify the '' at the beginning of the file with the same base_url of selfoss :

define('BASE_URL', '');

I don't know if it will be ok because I've used MyTool::getUrl() and it may be problematic on some links. Just let me know if it changes a bit

foch commented 11 years ago

I have a similar problem with the current stable version, my web server is behind stunnel and sslh, hence I do port forwarding to HTTP on port 80, and I can't connect over HTTPS unless I hardcode in MyTool::getUrl()

$https = true;

The funny thing is that Shaarli works just fine, even though it uses a very similar code to get the URL! I found it in

function serverUrl()

Any idea? merci !

tontof commented 11 years ago

That's strange because I've just added some isset to the shaarli code. If you replace in the MyTool::getUrl function :

        $https = (!empty($_SERVER['HTTPS'])                                     
                  && (strtolower($_SERVER['HTTPS']) == 'on'))                   
            || (isset($_SERVER["SERVER_PORT"])                                  
                && $_SERVER["SERVER_PORT"] == '443'); // HTTPS detection.       
        $serverport = (!isset($_SERVER["SERVER_PORT"])                          
                       || $_SERVER["SERVER_PORT"] == '80'                       
                       || ($https && $_SERVER["SERVER_PORT"] == '443')          
                       ? ''                                                     
                       : ':' . $_SERVER["SERVER_PORT"]);

by

        $https = (!empty($_SERVER['HTTPS'])                                     
                  && (strtolower($_SERVER['HTTPS']) == 'on'))                   
            || $_SERVER["SERVER_PORT"] == '443'; // HTTPS detection.       
        $serverport = ($_SERVER["SERVER_PORT"] == '80'                       
                       || ($https && $_SERVER["SERVER_PORT"] == '443')          
                       ? ''                                                     
                       : ':' . $_SERVER["SERVER_PORT"]);

Does it work ?

foch commented 11 years ago

No, I have the same problem :/ (and there is an extra parenthesis in your code :) I actually don't understand how it's possible for the script to detect that it's HTTP or HTTPS, because the HTTPS is hidden for my web server, stunnel taking transparently care of the SSL layer. But once again, Shaarli works surprisingly fine! Maybe a "Force HTTPS" checkbox in the configuration page would help.

tontof commented 11 years ago

I've deleted the extra parenthesis.

Well I think that if it works for shaarli it's not a good idea to hack this problem using a checkbox. Did you try using the BASE_URL parameter with the developpement version ? I guess it should resolve the problem, even if I don't understand why it works for shaarli without this.

foch commented 11 years ago

Well it's working better, but I had to hack the code and add the following lines at the beginning of MyTool::getUrl() since it's called everywhere

    public static function getUrl()
    {
       $base = BASE_URL;
       if (!empty($base)) {
          return $base;
       }
       ...

I don't know the impacts so I'm not proposing a pull request... plus I have some bugs with the dev version, I can't see the configuration buttons! I don't know if it's due to my hack... Merci :)

tontof commented 11 years ago

Well I definitely have too correct the use of getUrl/BASE_URL which is too buggy.

What do you mean by conf buttons (Cancel and Save modifications) ?

foch commented 11 years ago

I meant the buttons/links (depending on the skin) to add a feed for instance, or to access the config menu. But it's probably my "Orangina Rouge" skin which is not compatible with the latest dev version... Good luck fixing, in the mean time, I'm falling back to v7 with my nice hardcode!

tontof commented 11 years ago

Can you try with the new version in src : https://raw.github.com/tontof/kriss_feed/master/src/index.php

You can now create a plugin file base.php in plugins directory with :

<?php
$GLOBALS['BASE_URL'] = 'http://yoururl:8080/kriss/feed/path';
tontof commented 11 years ago

If it does not work, don't hesitate to reopen the issue

Riduidel commented 11 years ago

Doesn't work in default mode : all links now have the port number added as a prefix. i will try to use the plugin method this later

Beside, i don't know how to reopen an issue with github system ...

tontof commented 11 years ago

I guess only me is allowed to reopen :-)

Riduidel commented 11 years ago

Ok, It worked with the `plugins/base.php file.

BUT that file content was

 <?php
 $GLOBALS['BASE_URL'] = 'http://yoururl/kriss/feed/path';
 ?>

Do notice I removed the port number (as leaving it would leave me in the exact situation of that bug.

tontof commented 11 years ago

Great thanks :-)