1
mercibe
Problem getting Xoops working through a proxy server
  • 2003/10/24 12:51

  • mercibe

  • Just popping in

  • Posts: 55

  • Since: 2003/6/12


Hi,

We have just configured our corporate proxy server to map our XOOPS machine to our standard staging Intranet URL.

http://www.intranet.com:8081/ => http://158.166.248.205/

We adapted the XOOPS virtual path (mainfile.php):

// XOOPS Virtual Path (URL)
define('XOOPS_URL', 'http://www.intranet.com:8081');

... and now we have a blank page when we connect through the proxy. If we restore the old value of the XOOPS_URL (http://158.166.248.205) we can connect trough the proxy but, of course, only for the "home" page. All other links point to the IP address.

I suppose that something goes wrong with the ":" in the XOOPS_URL. Do you have any idea ?

Thank you in advance for your help.

BM

2
mercibe
Re: Problem getting Xoops working through a proxy server
  • 2004/1/20 12:45

  • mercibe

  • Just popping in

  • Posts: 55

  • Since: 2003/6/12


I finally found the problem and it is not related to the port number but simply to the way the module name is extracted from the requested URI that is particular when XOOPS installation is accessed via a proxy server.

It is around line 236 in /include/common.php (Xoops 2.0.5.2)

Quote:
$url_arr = explode('/', str_replace(str_replace('https://', 'http://', XOOPS_URL.'/modules/'), '', 'http://'.$HTTP_SERVER_VARS['HTTP_HOST'].$xoopsRequestUri));


It seems that this line extracts the module name from the requested URI. It works perfectly well when you have a direct access to the server. But once XOOPS is behind a proxy server, the HTTP_HOST is the real host (not the "domain" used to access XOOPS through the proxy) and so is different from XOOPS_URL => no module name can be extracted.

I do not really understand the reason why this "module name extraction" line has been written like that. It might be right...

I replaced this line by the following one

$url_arr explode('/',strstr($xoopsRequestUri,'/modules/'));


... and modified the line after

$xoopsModule =& $module_handler->getByDirname($url_arr[2]);


... to adapt the url_arr array index.

Am I the only one on earth that access a XOOPS installation through a proxy ????!!!!

I really don't know if this is the best way to do or if it is really a bug ! Anyway it solve my proxy problem.

I really would like to have a piece of good advice on the following point: since all links in XOOPS are build from XOOPS_URL variable defined in mainfile.php, you are only able to access you site in one and only one way. Am I right ? I would like to achieve the following: access the same site 1.directly (no proxy), 2. through an HTTP proxy and 3. through another HTTPS proxy. Do I have to write some code in mainfile.php to dynamically adapt XOOPS_URL ? Does it exist another mean ?

Thank you very much in advance for your answers.

Kind regards,

Benoit

3
mercibe
Re: Problem getting Xoops working through a proxy server
  • 2004/1/20 13:13

  • mercibe

  • Just popping in

  • Posts: 55

  • Since: 2003/6/12


Am I talking to myself ?

I found answers to all my questions !

First of all, there is another place where the "module name extraction" fails: in /include/cp_header.php (around line 9).
So you have to correct it the same way (cfr. previous post).

Second: I simply change my full absolute virtual path (XOOPS_URL in mainfile.php) to a semi-relative (or semi-absolute !) one.

http://www.mydomain.com/MyApplication => /MyApplication

Now, I have just tried to use my XOOPS application via 3 different means and it works perfectly well (just a bit slower through my SSL proxy )

May I ask to one of the member of the "dream team" (the core one !) to confirm my discovery and , if needed, to correct that bug in the 2 core files ?

Thank you !

Benoit


4
CBlue
Re: Problem getting Xoops working through a proxy server on port other than 80...

Sorry Benuit! You have been talking to yourself and finding your own answers because if anyone was able to help you, they would have responded. But none of the ones that may help you have been online yet, since your posts this morning.

5
mercibe
Re: Problem getting Xoops working through a proxy server
  • 2004/1/20 21:53

  • mercibe

  • Just popping in

  • Posts: 55

  • Since: 2003/6/12


Oups... watch out...

I discovered some strange behaviors in Admin tools (does not save new block in DB for instance) since I have changed the XOOPS_URL to a "semi-relative" path as peviously descibed. I will double check and update this forum as soon as I found a solution.

Ideas are welcome.

Benoit

6
mercibe
How to make Xoops working behind a proxy server: end of the story ?
  • 2004/1/21 12:23

  • mercibe

  • Just popping in

  • Posts: 55

  • Since: 2003/6/12


The strange behaviors mentionned in my previous post came from the xoops_refcheck function (in /include/functions.php). All INSERT and UPDATE database statements was rejected.

This function is called from /include/common.php ("Connect to DB" code), /include/cp_functions.php (xoopsfwrite function) and banners.php (clickbanner function).

Its role and meaning are unclear for me (related to XMLRPC ?). Nevertheless I adapted the code to make it work with proxy (and thus "semi-absolute" XOOPS_URL, but also full one) while trying to keep the original idea.

So this is the new code:

Quote:

function xoops_refcheck($docheck=1)
{

$ref = stristr(str_replace('https://','',str_replace('http://','',xoops_getenv('REQUEST_URI'))),'/');

$xurl = stristr(str_replace('https://','',str_replace('http://','',XOOPS_URL)),'/');

if ($docheck == 0) {
return true;
}
if ($ref == '') {
return false;
}

if (strpos($ref, $xurl) !== 0 ) {
return false;
}
return true;
}



SUMMARY

To make XOOPS working behind a proxy and/or with the possibility to use a "semi-relative" XOOPS_URL you have to modify two files: /include/common.php (modify two lines as described previously in this topic) and /include/functions.php (see above).

I have, once again, tested the proposed solution in the following ways:
- direct access to the hosting machine - XOOPS_URL = full
- direct access to the hosting machine - XOOPS_URL = semi-relative
- access through a HTTP proxy - XOOPS_URL = semi-relative (mandatory in case of proxy usage)
- access through a HTTPS proxy - XOOPS_URL = semi-relative (mandatory in case of proxy usage)

All my tests passed succesfully (read/write normal operations for registered users + some read/write admin operations).

I would really appreciate to have some comments from one of the core developper. I think these modifications are really important and might be included in the new XOOPS version.

Thank you.

Benoit




7
matias
Re: How to make Xoops working behind a proxy server: end of the story ?
  • 2004/1/30 13:37

  • matias

  • Just popping in

  • Posts: 2

  • Since: 2003/5/9 1


First of all, thank you very much for your contribution, mercibe !!

After migrating our XOOPS from W2S (IIS5) to W2003S (IIS6), I’ve spent five days to solve all the proxy troubles with our web (It’s based on XOOPS 2.0.5.2 too), until I've read these appreciated posts.

Here you have my comments:

- Microsoft ISA Server & Proxy (all request to port 80 redirects to port 90)

- I’ve had to apply your hacks to the files “include/common.php” (at line 236) and “include/cp_header.php” (at line 9), to resolve the strange behaviour of the “$url_arr” variable ; I’ve been receiving many times the following error message: “selected module does not exists” -> _MODULENOEXIST, on the “news” XOOPS main page as well as on the Administrator Control Panel.

- Concerning the mysql_DB, I haven’t needed to hack the “include/functions.php”, neither the semi-relative path that you have mentioned (XOOPS_URL) in “mainfile.php”, because all read/write to the database were passed successfully.

Well, I agree with you too; please, these modifications could be kept in mind from someone of the core team.

Hoping help anyone, again, TIA!

Please, you can see our web at:

http://www.uxsystems.com

M.

8
mercibe
Xoops and proxy: wrap-up
  • 2004/2/8 20:52

  • mercibe

  • Just popping in

  • Posts: 55

  • Since: 2003/6/12


Xoops 2.0.6 is out. Now I think it is time to wrap-up at least one important thing that should (must IMHO) be integrated in the next release.

When you have to setup an intranet website, you often need to access your website from different URL's.

Here are some examples:

- http://computername/xoops
- http://158.166.248.205/xoops
- http://www.intranetdomain.com/xoops (linked to http://dns_machinename/xoops via a proxy server)
- https://www.extranetdomain.com/xoops (accessible from the outside world - linked to http://dns_machinename/xoops via a proxy server)

All these URLs point to the same machine/web server. The 2 first ones do not imply the use of a proxy server. The third and fourth ones are proxy mappings.

Where is the problem with XOOPS ?

No real problems, just some bad uses of the XOOPS_URL constant. If you want to achieve the previously described configuration, you MUST use a XOOPS_URL without any domain information, thus use a semi-absolute url. With the previous examples, the XOOPS_URL constant must contain /xoops.

What does it mean ?

Mainly three things:

1. 3 system files have to be adapted (/include/common.php,/include/functions.php, /include/checklogin.php).

2. Module developers have to think twice when they use XOOPS_URL for other reasons that simple HTML anchors or redirections

3. All notification messages (system or modules ones) should be adapted to use a "default" domain name in links (via XOOPS_DEFAULT_DOMAIN constant? my solution today) or proposing a list of valid URLs. This is mandatory because you never know from where a mail is read...


I have a working version of XOOPS 2.0.5.2 running in production that implements the small system hacks described in this post (7 lines in three files !!!) that works perfectly well and is fully compatible with "full" XOOPS_URL.

Of course if you want to work with this configuration AND have working links in notifications, you will have to adapt other files (mainfile.php, kernel/notification.php, class/xoopsmailer.php, include/comment_post.php, register.php, lostpass.php).

For all other module specific notifications, you might want to adapt certain files. I have all this infomation available for those who cares.

THESE MODIFICATIONS ARE FULLY COMPATIBLE WITH CURRENT XOOPS BEHAVIOR.

Conclusion

My conclusion is: why wait to add it to XOOPS ? Would XOOPS be the first CMS on earth not working in an Intranet/Extranet configuration ?

I am fully available to help and discuss with Core members, if they finally react to my repeated posts. I fully understand that you are very busy guys ! You can count on me to help you. Do you need incentives?

Best regards,

Benoit

9
Mithrandir
Re: Xoops and proxy: wrap-up

Could you say exactly what needs to be done in common.php, functions.php and checklogin.php and what module devs should do?

Thanks for your great work.

10
mercibe
Xoops and proxy: summary of modifications needed
  • 2004/2/10 20:06

  • mercibe

  • Just popping in

  • Posts: 55

  • Since: 2003/6/12


Hi Mithrandir,

Please find hereafter:

- a summary of what have to be modified in common.php, cp_header.php, functions.php and checklogin.php (even this was already explained in my previous posts )
- a short list of recommendations for module developpers

Core file modifications

1. XOOPS_ROOT_PATH/include/common.php - around line 236 (Xoops 2.0.5.2)

Replace
Quote:

$url_arr = explode('/', str_replace(str_replace('https://', 'http://', XOOPS_URL.'/modules/'), '', 'http://'.$HTTP_SERVER_VARS['HTTP_HOST'].$xoopsRequestUri));

by
Quote:

$url_arr = explode('/',strstr($xoopsRequestUri,'/modules/'));

... and modify the line 1 line after
Quote:

$xoopsModule =& $module_handler->getByDirname($url_arr[2]);


2. XOOPS_ROOT_PATH/include/cp_header.php - around line 9 (Xoops 2.0.5.2)

Replace
Quote:

$url_arr = explode('/', str_replace(str_replace('https://', 'http://', XOOPS_URL.'/modules/'), '', 'http://'.$HTTP_SERVER_VARS['HTTP_HOST'].$xoopsRequestUri));

by
Quote:

$url_arr = explode('/',strstr($xoopsRequestUri,'/modules/'));

... and modify the line 1 line after
Quote:

$xoopsModule =& $module_handler->getByDirname($url_arr[2]);


3. XOOPS_ROOT_PATH/include/functions.php - around line 137 (Xoops 2.0.5.2)

Modify the xoops_refcheck function

Quote:

function xoops_refcheck($docheck=1)
{

$ref = stristr(str_replace('https://','',str_replace('http://','',xoops_getenv('REQUEST_URI'))),'/');

$xurl = stristr(str_replace('https://','',str_replace('http://','',XOOPS_URL)),'/');

if ($docheck == 0) {
return true;
}
if ($ref == '') {
return false;
}

if (strpos($ref, $xurl) !== 0 ) {
return false;
}
return true;
}


4. XOOPS_ROOT_PATH/include/checklogin.php - around line 76 (Xoops 2.0.5.2)

add the following "elseif" condition before the "else"

Quote:

if (!empty($HTTP_POST_VARS['xoops_redirect']) && !strpos($HTTP_POST_VARS['xoops_redirect'], 'register')) {
$parsed = parse_url(XOOPS_URL);
$url = isset($parsed['scheme']) ? $parsed['scheme'].'://' : 'http://';
if (isset($parsed['host'])) {
$url .= isset($parsed['port']) ?$parsed['host'].':'.$parsed['port'].trim($HTTP_POST_VARS['xoops_redirect']): $parsed['host'].trim($HTTP_POST_VARS['xoops_redirect']);

} elseif(substr(trim(XOOPS_URL),0,1)=="/") {
$url = trim($HTTP_POST_VARS['xoops_redirect']);
}

else {
$url = xoops_getenv('HTTP_HOST').trim($HTTP_POST_VARS['xoops_redirect']);
}
} else {
$url = XOOPS_URL.'/index.php';
}


Recommendations

In order to make XOOPS and modules available and working properly from behind a proxy (or other configurations allowing you to access your site from different URLs), you have to ensure that:

- you only use XOOPS_URL for simple HTML anchors or redirections
- All notification messages (system or modules ones) should be adapted to use a "default" domain name in links (to prepend to XOOPS_URL). This could be achieved by creating a new constant in mainfile.php - XOOPS_DEFAULT_DOMAIN or proposing a list of valid URLs(array constant in mainfile.php). This is mandatory because you never know from where a mail is read...

Examples:
mainfile.php
XOOPS_URL = "/mysite"; // or simply "/"
XOOPS_DEFAULT_DOMAIN = "http://www.mycompany.com";

php code snippet
$comment_tags['X_COMMENT_URL'] = XOOPS_DEFAULT_DOMAIN.XOOPS_URL . '/modules/'..........

Of course, if you defined a complete XOOPS_URL (current way of working today), you will have to leave XOOPS_DEFAULT_DOMAIN empty !!!

OK, I know you will ask me which system files have to be modified...
- mainfile.php (new constant)
- /kernel/notification.php, /class/xoopsmailer.php, /include/comment_post.php, /lostpass.php and /register.php => prepend XOOPS_DEFAULT_DOMAIN to all XOOPS_URL usage

OK, would you like the same info for some basic modules (NON exaustive - main examples => prepend XOOPS_DEFAULT_DOMAIN to all XOOPS_URL usage)?
News: look for STORY_URL and WAITINGSTORIES_URL in news/submit.php
NewBB: look for POST_URL, THREAD_URL and FORUM_URL in newbb/post.php and newbb/include/notification.inc.php
Download: look for FILE_URL, CATEGORY_URL, BROKENREPORTS_URL, MODIFYREPORTS_URL and WAITINGFILES_URL in /download/submit.php, /download/admin/index.php, /download/brokenfile.php and /download/modfile.php

And I repeat it:
THESE MODIFICATIONS ARE FULLY COMPATIBLE WITH CURRENT XOOPS BEHAVIOR.

I hope this will help. This is just a summary and you can always read the all story for details and justifications.

Benoit

Login

Who's Online

184 user(s) are online (140 user(s) are browsing Support Forums)


Members: 0


Guests: 184


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Dec 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits