Details

  • Type: Bug Bug
  • Status: Open Open (View Workflow)
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: Web Interface
  • Labels:
    None
  • Environment:

    Apache/2.2.22 (FreeBSD 8.2-RELEASE-amd64) mod_ssl/2.2.22 OpenSSL/0.9.8q PHP/5.3.10 with Suhosin-Patch

Description

Observium expects to be invoked using "/" as the base_uri. If you install observium in a different URI location (e.g. http://www.example.com/observium/), then you can no longer access any menu item because the URI processing is broken. The correct URI can be found in the PATH_INFO variable (i.e. what Rewrite says the URI ought to be) rather than in the REQUEST_URI variable (which is what was typed into the browser). See attached diff.

Activity

Hide
Tom Laermans added a comment -

This is by design, a subdirectory is not supported.

Further more, PATH_INFO munges characters so it's not a usable field unfortunately (for example, it changes ' to ?, which is unacceptable to me).

Other ways of dealing with this welcome.

Show
Tom Laermans added a comment - This is by design, a subdirectory is not supported. Further more, PATH_INFO munges characters so it's not a usable field unfortunately (for example, it changes ' to ?, which is unacceptable to me). Other ways of dealing with this welcome.
Hide
Dennis de Houx added a comment -

Could you try setting the $config['base_url'] = "http://<server>/<dir>"; in the config file and see if that works

Show
Dennis de Houx added a comment - Could you try setting the $config['base_url'] = "http://<server>/<dir>"; in the config file and see if that works
Hide
Sander Steffann added a comment - - edited

Dennis: I tried that yesterday, but all the images were broken

Show
Sander Steffann added a comment - - edited Dennis: I tried that yesterday, but all the images were broken
Hide
Tom Laermans added a comment -

That shouldn't happen, as the base_url is set as html base and all images are relative...

Show
Tom Laermans added a comment - That shouldn't happen, as the base_url is set as html base and all images are relative...
Hide
Sander Steffann added a comment - - edited

I'll try again... And must admin I was wrong

After changing the 'base_url' in config.php and html/.htaccess the images do work, but all URLs show the Recent Eventlog Entries page. Using $_SERVER['PATH_INFO'] in index.php works great though. I haven't found a single problem.

So, as far as I can see these are the changes necessary for running observium in a subdir:

  • Create an Alias in the apache config, like:
    Alias /observium /opt/observium/html
  • Set the base_url in config.php:
    $config['base_url'] = "http://www.example.com/observium/";
    The trailing / is required!
  • Set the rewrite-base in html/.htaccess:
    RewriteBase /observium/
    The trailing / is required!
  • Change the following line in html/index.php:
    $segments = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
    to:
    $segments = explode('/', trim($_SERVER['PATH_INFO'], '/'));
Show
Sander Steffann added a comment - - edited I'll try again... And must admin I was wrong After changing the 'base_url' in config.php and html/.htaccess the images do work, but all URLs show the Recent Eventlog Entries page. Using $_SERVER['PATH_INFO'] in index.php works great though. I haven't found a single problem. So, as far as I can see these are the changes necessary for running observium in a subdir:
  • Create an Alias in the apache config, like: Alias /observium /opt/observium/html
  • Set the base_url in config.php: $config['base_url'] = "http://www.example.com/observium/"; The trailing / is required!
  • Set the rewrite-base in html/.htaccess: RewriteBase /observium/ The trailing / is required!
  • Change the following line in html/index.php: $segments = explode('/', trim($_SERVER['REQUEST_URI'], '/')); to: $segments = explode('/', trim($_SERVER['PATH_INFO'], '/'));
Hide
Tom Laermans added a comment -

If it doesnt work, note the <base> tag in the html and check what files your browser is requesting in your apache access log...

Show
Tom Laermans added a comment - If it doesnt work, note the <base> tag in the html and check what files your browser is requesting in your apache access log...
Hide
Sander Steffann added a comment - - edited

@Tom: I forgot the trailing / ...

Show
Sander Steffann added a comment - - edited @Tom: I forgot the trailing / ...
Hide
Adam Armstrong added a comment - - edited

anything requiring changing .htaccess is a no-go for us, as we maintain that file in SVN.

Show
Adam Armstrong added a comment - - edited anything requiring changing .htaccess is a no-go for us, as we maintain that file in SVN.
Hide
Sander Steffann added a comment -

@Adam: I thought as much I still wanted to document it here for people who want to modify their local setup.

Show
Sander Steffann added a comment - @Adam: I thought as much I still wanted to document it here for people who want to modify their local setup.
Hide
Adam Armstrong added a comment -

We don't want people to modify things.

Show
Adam Armstrong added a comment - We don't want people to modify things.
Hide
Sander Steffann added a comment -

@Adam: What a weird thing to say. This is an open source project. Of course people can and will modify it... That is why you release it under GPLv3, right? I understand that you don't want to offer support for such modifications though.

Show
Sander Steffann added a comment - @Adam: What a weird thing to say. This is an open source project. Of course people can and will modify it... That is why you release it under GPLv3, right? I understand that you don't want to offer support for such modifications though.
Hide
Sander Steffann added a comment -

Anyway, as you can see from my other bug reports and suggested improvement: I am extensively modifying my local setup

Show
Sander Steffann added a comment - Anyway, as you can see from my other bug reports and suggested improvement: I am extensively modifying my local setup
Hide
Adam Armstrong added a comment -

Not really. We are GPL because the GPL is a cancer, and we couldn't not be GPL once we used GPL'd code.

We DO NOT want people to modify things, except to provide patches and improvements upstream. If you don't understand why, look at the fragmentation of Android.

Once someone has modified their install and not provided the modifications to us (and thus broken the SVN mechanism), we no longer want to hear from them, and no longer consider them users of Observium.

Show
Adam Armstrong added a comment - Not really. We are GPL because the GPL is a cancer, and we couldn't not be GPL once we used GPL'd code. We DO NOT want people to modify things, except to provide patches and improvements upstream. If you don't understand why, look at the fragmentation of Android. Once someone has modified their install and not provided the modifications to us (and thus broken the SVN mechanism), we no longer want to hear from them, and no longer consider them users of Observium.
Hide
Tom Laermans added a comment -

(unless, obviously, patches are supplied).

People can modify whatever they want, but the support burden is indeed not something we want to carry, if people break their setup by their own actions

Show
Tom Laermans added a comment - (unless, obviously, patches are supplied). People can modify whatever they want, but the support burden is indeed not something we want to carry, if people break their setup by their own actions
Hide
Sander Steffann added a comment -

Of course! As usual: if you break it, you get to keep the pieces

Show
Sander Steffann added a comment - Of course! As usual: if you break it, you get to keep the pieces
Hide
Chris Bennett added a comment -

Hi there,

I too wanted Observium to work under a subdirectory of the root web server - Sander, I'd already done the steps you suggested but I found one more required to make cookies happy & to support multiple instances of observium off of the same hostname/web site.

  • config.php:
    $config['base_url_path'] = "/observium";
  • html/includes/authenticate.inc.php
    --- html/includes/authenticate.inc.php	(revision 3087)
    +++ html/includes/authenticate.inc.php	(working copy)
    @@ -25,9 +25,9 @@
       dbInsert(array('user' => $_SESSION['username'], 'address' => $_SERVER["REMOTE_ADDR"], 'result' => 'Logged Out'), 'authlog');
       unset($_SESSION);
       session_destroy();
    -  header('Location: /');
    -  setcookie ("username", "", time() - 60*60*24*100, "/");
    -  setcookie ("password", "", time() - 60*60*24*100, "/");
    +  header('Location: ' . $config['base_url_path']);
    +  setcookie ("username", "", time() - 60*60*24*100, $config['base_url_path']);
    +  setcookie ("password", "", time() - 60*60*24*100, $config['base_url_path']);
       $auth_message = "Logged Out";
     }
     
    @@ -74,8 +74,8 @@
         }
         if (isset($_POST['remember']))
         {
    -      setcookie("username", $_SESSION['username'], time()+60*60*24*100, "/");
    -      setcookie("password", $_SESSION['password'], time()+60*60*24*100, "/");
    +      setcookie("username", $_SESSION['username'], time()+60*60*24*100, $config['base_url_path']);
    +      setcookie("password", $_SESSION['password'], time()+60*60*24*100, $config['base_url_path']);
         }
         $permissions = permissions_cache($_SESSION['user_id']);
    
    

With the changes you documented above, and the authenticate.php change, I havn't seen any problems.

It would be great to see the developers look at this again as hosting observium under a subdirectory is much more preferable for me and likely others when you have other tools also under a directory path.

I'll attach a patch with my whole set of changes for consideration.

Show
Chris Bennett added a comment - Hi there, I too wanted Observium to work under a subdirectory of the root web server - Sander, I'd already done the steps you suggested but I found one more required to make cookies happy & to support multiple instances of observium off of the same hostname/web site.
  • config.php: $config['base_url_path'] = "/observium";
  • html/includes/authenticate.inc.php
    --- html/includes/authenticate.inc.php	(revision 3087)
    +++ html/includes/authenticate.inc.php	(working copy)
    @@ -25,9 +25,9 @@
       dbInsert(array('user' => $_SESSION['username'], 'address' => $_SERVER["REMOTE_ADDR"], 'result' => 'Logged Out'), 'authlog');
       unset($_SESSION);
       session_destroy();
    -  header('Location: /');
    -  setcookie ("username", "", time() - 60*60*24*100, "/");
    -  setcookie ("password", "", time() - 60*60*24*100, "/");
    +  header('Location: ' . $config['base_url_path']);
    +  setcookie ("username", "", time() - 60*60*24*100, $config['base_url_path']);
    +  setcookie ("password", "", time() - 60*60*24*100, $config['base_url_path']);
       $auth_message = "Logged Out";
     }
     
    @@ -74,8 +74,8 @@
         }
         if (isset($_POST['remember']))
         {
    -      setcookie("username", $_SESSION['username'], time()+60*60*24*100, "/");
    -      setcookie("password", $_SESSION['password'], time()+60*60*24*100, "/");
    +      setcookie("username", $_SESSION['username'], time()+60*60*24*100, $config['base_url_path']);
    +      setcookie("password", $_SESSION['password'], time()+60*60*24*100, $config['base_url_path']);
         }
         $permissions = permissions_cache($_SESSION['user_id']);
    
    
With the changes you documented above, and the authenticate.php change, I havn't seen any problems. It would be great to see the developers look at this again as hosting observium under a subdirectory is much more preferable for me and likely others when you have other tools also under a directory path. I'll attach a patch with my whole set of changes for consideration.
Hide
Adam Armstrong added a comment -

If we commit this, it will only break again in 3 months time when we next change something.

Show
Adam Armstrong added a comment - If we commit this, it will only break again in 3 months time when we next change something.
Hide
Chris Bennett added a comment -

Patch to support hosting Observium in a location other than the webroot.

Includes handling of cookie variables to support multiple instances of Observium on the same web server hostname.

Show
Chris Bennett added a comment - Patch to support hosting Observium in a location other than the webroot. Includes handling of cookie variables to support multiple instances of Observium on the same web server hostname.
Hide
Chris Bennett added a comment -

Hi Adam,

Hmm you can make that case for any change to the codebase... It's just this particular change/feature is something the core developers don't have a use for so you understandably don't want to support it.

If enough people express interest in having support for this, it would be good to have it rolled in to trunk in some form.. For the time being it's a simple patch I'm happy to manage outside the tree.

Thanks for the quick response.

Show
Chris Bennett added a comment - Hi Adam, Hmm you can make that case for any change to the codebase... It's just this particular change/feature is something the core developers don't have a use for so you understandably don't want to support it. If enough people express interest in having support for this, it would be good to have it rolled in to trunk in some form.. For the time being it's a simple patch I'm happy to manage outside the tree. Thanks for the quick response.
Hide
Nick Hilliard added a comment -

uh, you could make this into a supported feature. it looks to me like several observium users are actually interested in it.

There is one SVN issue, namely .htaccess. This can be documented. If you want, once there is some way of supporting this in the code, I'll write up some wiki text about how it works and what you need to do when you're updating.

Show
Nick Hilliard added a comment - uh, you could make this into a supported feature. it looks to me like several observium users are actually interested in it. There is one SVN issue, namely .htaccess. This can be documented. If you want, once there is some way of supporting this in the code, I'll write up some wiki text about how it works and what you need to do when you're updating.
Hide
Adam Armstrong added a comment -

No.

Stop being lazy douchebags and create subdomains.

Show
Adam Armstrong added a comment - No. Stop being lazy douchebags and create subdomains.
Viewable by All Users

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated: