Forum

non-standard port number appended to URL

Gour
5 December 2012, 22:24
Hello!

I can only use Hiawatha behind nginx working as reverse-proxy.

My setup is as follows:
Binding {
Port = 64915
Interface = 127.0.0.1

...
FastCGIserver {
FastCGIid = PHP5
ConnectTo = 127.0.0.1:64878
Extension = php
}

VirtualHost {
Hostname = atmarama.sites.djangohosting.ch
WebsiteRoot = /some/path/tiki
StartFile = index.php
AccessLogfile = /some/path/tiki-access.log
ErrorLogfile = /some/path/tiki-error.log
TimeForCGI = 5
UseFastCGI = PHP5
# UseToolkit = banshee
}


and when I want to access previously installed site at: http://atmarama.sites.djangohosting.ch/ I'm redirected to http://atmarama.sites.djangohosting.ch:64915/, iow. local port where Hiawatha is listening is appended to the URL.

How to get rid of it or what do I miss in my setup?

Is there some way to use Search function to look into old posts when looking for an answer?


Sincerely,
Gour



Hiawatha version:
Operating System:
Hugo Leisink
6 December 2012, 09:29
Hiawatha doesn't do any kind of redirecting, unless you tell it to do so (RequireSSL setting or via an UrlToolkit rule). So, my guess is that the redirection comes from your previously installed website. I think it somehow registered it was installed via port 64915 and want to continue to use that port. Have you checked its settings?
Gour
6 December 2012, 10:43
> So, my guess is that the redirection comes from your previously installed website. I think it somehow registered it was installed via port 64915 and want to continue to use that port.

Well, I did re-install it (Tiki) and it correctly shows test.php in the root, but it fails connectiong to the site by appending port number to the URL.

Here are log outputs for those two cases.

127.0.0.1|Thu 06 Dec 2012 10:34:05 +0100|200|2295||GET /test.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.0|Host: atmarama.sites.djangohosting.ch|X-Real-IP: 93.139.208.158|X-Forwarded-For: 93.139.208.158|X_FORWARDED_PROTO: http|X_FORWARDED_PROTOCOL: http|SCHEME: http|Connection: close|User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20100101 Firefox/10.0.11 Iceweasel/10.0.11|Accept: image/png,image/*;q=0.8,*/*;q=0.5|Accept-Language: en,hr;q=0.5|Accept-Encoding: gzip, deflate|Referer: http://atmarama.sites.djangohosting.ch/test.php
127.0.0.1|Thu 06 Dec 2012 10:34:47 +0100|302|482||GET / HTTP/1.0|Host: atmarama.sites.djangohosting.ch|X-Real-IP: 93.139.208.158|X-Forwarded-For: 93.139.208.158|X_FORWARDED_PROTO: http|X_FORWARDED_PROTOCOL: http|SCHEME: http|Connection: close|User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20100101 Firefox/10.0.11 Iceweasel/10.0.11|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8|Accept-Language: en,hr;q=0.5|Accept-Encoding: gzip, deflate

I'll try to install something else and how it goes...
Gour
6 December 2012, 12:11
I moved one WP site to be server by Hiawatha (behind nginx) and it works.

Now trying to move another site (Concrete5), but it rewrite rules for it does not work and C5 installer complains about rewriteURL support...

However, I'll try to get more insight about (original) Tiki problem as well...
Gour
6 December 2012, 18:22
I re-installed everything from the scratch and the problem persists.

However, I can say that the same site works with both Apache2 & Nginx working behind reverse proxy.

Should I try with lighty & Cherokee to confirm that it might be problem with Hiawatha?
Gour
6 December 2012, 21:29
This setting helped:

StartFile = tiki-index.php

Gour
6 December 2012, 21:33
Well, not fully...log out from the 'admin', appends port number as well.
Hugo Leisink
6 December 2012, 21:46
I think you have a better change of finding an answer to your problem at the tiki forum. It's not that I don't want to help you, but I don't know the answer because I don't think it's a Hiawatha issue. Hiawatha doesn't do any redirecting in this situation.
Gour
6 December 2012, 22:56
In the meantime I did try with lighttpd and it's he same problem, so it looks that nginx (reverse-proxy) is misconfigured on the server...it, somehow, works with Apache, but fails with other servers.
Hugo Leisink
6 December 2012, 23:55
Ah, an Apache-only setup... heard that before.
Gour
11 December 2012, 17:27
I've taken 1-month subscription for another hosting and - same problem.

Moreover, tried with the same setup - nginx as reverse-proxy and Hiawatha server running on non-80 and unprivileged port by installing latest stable versions of Joomla, Drupal, SilverStripe, ProcessWite, CMS Made Simple, Concrete5.WordPress & Typo3 and although some need Apache for install (due to URL rewriting), none displays this problem of appending local port to the URL.

I had same issue in the past with MODx [forums.modx.com], submitted ticket [tracker.modx.com], but the devs decided:
Does this still need to be implemented? I don't think it does if everyone agrees that the server should always report the front-end port used by the proxy.


What do you think about such resolution? (I do not care about MODx, just curious if it's correct?)

I also wonder if HideProxy & ReverseProxy setting has anything with my issues?


Sincerely,
Gour
Gour
11 December 2012, 19:11
I've found the workaround, but it's not proper fix which should include detection if the server is running behind reverse-proxy. Any idea about it?
Hugo Leisink
11 December 2012, 19:20
The only place where Hiawatha adds a port number to an URL is in the Location HTTP header in case of a 301 error. I've changed that in this test release [www.leisink.net]. If this version doesn't solve your problem, it's probably not a Hiawatha issue.
Gour
11 December 2012, 20:24
Well, the problem is in the Tiki code:

See this (tiki/lib/setup/absolute_urls.php):

if (isset($_SERVER['SERVER_PORT'])) {
if (($_SERVER['SERVER_PORT'] != 80) &&
($_SERVER['SERVER_PORT'] != 443)) { if (( isset($_SERVER['HTTPS']) &&
$_SERVER['HTTPS'] == 'on' )) { $prefs['https_port'] = (int)
$_SERVER['SERVER_PORT']; }
else {
$prefs['http_port'] = (int) $_SERVER['SERVER_PORT']; }
}
}


The above snippet, in my case, sets the http_port to the local port number where Hiawatha is listening.

I did create dirty 'workaround' in the code which follows:

if ( $prefs['https_port'] == 443 ) {
$prefs['https_port'] = '';
} else {
$prefs['http_port'] = '';
}


but the proper solution should involve some testing whether the server is behind reverse-proxy, no idea how, probably by checking X-Forwarded-For header etc.


This topic has been closed.