Merge branch 'master' of ssh://git.ikiwiki.info
[ikiwiki.git] / doc / bugs / Running_on_an_alternative_port_fails.mdwn
1 Can't appear to get 'wiki' functions (i.e. editing) running when ikiwiki is running on a port other than the default (port 80).  Somewhere in the processing it considers the base URL to exclude the port number and the websever throws back an error finding the page.
2
3 For example if you run on 'http://my.gear.xxx:8080/' then after clicking login (using default password auth) it will process and try to redirect you to 'http://my.gear.xxx/cgi-bin/ikiwiki.cgi'.  I'm assuming that somewhere we've used the 'path' and the 'host' and dropped the remainder.  I can figure out where this is yet but I'll post back if I get lucky.
4
5  -- fergus
6
7 NB: both the 'url' and the 'cgiurl' include the port and removing the port element provides the expected functionality.
8
9 ---
10
11 > I tried to reproduce this by making my laptop's web server use port
12 > 8080. Set up ikiwiki to use that in cgiurl and url, and had
13 > no problem with either openid or password auth login.
14
15 > Ikiwiki has had some changes in this area in the past year; you don't say
16 > what version you were using. It could also be a problem with your web
17 > server, conceviably, if didn't correctly communicate the port to the cgi
18 > program. --[[Joey]]
19
20 ---
21
22 >> I did think of that so threw a 'printenv' script to check the port was arriving 
23 right.
24
25 >>>     SERVER_PORT=8181  
26 >>>     HTTP_HOST=zippy0.ie0.cobbled.net  
27
28 >>>> In apache, `HTTP_HOST` includes the port. This is not part of the CGI
29 >>>> spec it seems, but perl's `CGI` module seems to rely on it,
30 >>>> in `virtual_port`:
31
32 <pre>
33     my $vh = $self->http('x_forwarded_host') || $self->http('host');
34     my $protocol = $self->protocol;
35     if ($vh) {
36         return ($vh =~ /:(\d+)$/)[0] || ($protocol eq 'https' ? 443 : 80);
37 </pre>
38
39 >>>> The `CGI` module only looks at `SERVER_PORT` when there's no
40 >>>> `HTTP_HOST`. So this is either a bug in perl's CGI or thttpd.
41 >>>> --[[Joey]]
42
43 >>>     HTTP_ACCEPT_LANGUAGE=en-ie, en  
44 >>>     PATH=/usr/local/bin:/usr/ucb:/bin:/usr/bin  
45 >>>     SCRIPT_NAME=/cgi-bin/printenv.sh  
46 >>>     HTTP_USER_AGENT=Mozilla/5.0 (X11; U; Linux i686; en-ie) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/531.2+ Ubuntu/10.10 () Epiphany/2.30.2  
47 >>>     PWD=/home/http1/www/cgi-bin  
48 >>>     REQUEST_METHOD=GET  
49 >>>     SERVER_SOFTWARE=thttpd
50 >>>     SERVER_NAME=zippy0  
51 >>>     SERVER_PROTOCOL=HTTP/1.1  
52 >>>     HTTP_ACCEPT_ENCODING=gzip  
53 >>>     GATEWAY_INTERFACE=CGI/1.1  
54 >>>     CGI_PATTERN=cgi-bin/*  
55 >>>     HTTP_COOKIE=ikiwiki_session_c%5E2%3Fsupport%3Dtrue=bdf13df0460966a607ba497967ea5ff4  
56 >>>     REMOTE_ADDR=10.0.0.1  
57 >>>     HTTP_ACCEPT=application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5  
58
59 >>Seems to be.  Using version from packaging system;
60
61 >>>     ikiwiki-3.20110905
62
63 >> which I'd guess is from Sep.  Will look for updates and post back if still
64 wrong.
65
66 >> Cheers
67
68 >> -- fergus
69
70 >> PS: all the links generated by CGI pages omit the port; this works if i login first and then
71 reset the server on the 'odd' port -- hovering over the links absolute links with the port missing.