Dear ikiwiki folks,

using Debian Wheezy and ikiwiki 3.20120629 for some reason when accessing the site using HTTP (and not HTTPS), going to Edit, so executing the CGI script, all URLs are prepended with HTTPS, which I do not want.

    <base href="https://www.example.org/" />

Trying to look at the source, I guess it is originating from IkiWiki/CGI.pm.

    sub printheader ($) {
        my $session=shift;

        if (($ENV{HTTPS} && lc $ENV{HTTPS} ne "off") || $config{sslcookie}) {
            print $session->header(-charset => 'utf-8',
                -cookie => $session->cookie(-httponly => 1, -secure => 1));
        }
        else {
            print $session->header(-charset => 'utf-8',
                -cookie => $session->cookie(-httponly => 1));
        }
    }

Does it check if HTTPS is enabled in the environment? During ikiwiki --setup example.setup or when the CGI script is run when the site is accessed (for example in an Apache environment)?

Can this somehow be disabled in ikiwiki. Reading the code I guess I could somehow set HTTPS = off somewhere in the VirtualHost section of the Apache configuration.

Thanks,

--?PaulePanter

IkiWiki generates self-referential URLs using the url and cgiurl configuration parameters, and the urlto() and cgiurl() functions; the code you quoted isn't involved (it's choosing whether to set HTTPS-only cookies or not, rather than choosing how to generate self-referential URLs).

If you want your wiki to be accessible via both HTTP and HTTPS, and use whichever the user first requested, you should set both url and cgiurl to the same URI scheme and hostname with no port specified, either both http or both https, for instance:

url: http://www.example.com/
cgiurl: http://www.example.com/ikiwiki.cgi

or

url: https://example.org/wiki/
cgiurl: https://example.org/cgi-bin/ikiwiki

(or the Perl-syntax equivalents if you're not using a YAML setup file).

If you use one of those, IkiWiki will attempt to generate path-only links, like "/wiki/" and "/cgi-bin/ikiwiki?...", whenever it's valid to do so. A visitor using HTTP will stay on HTTP and a visitor using HTTPS will stay on HTTPS.

The choice of http or https for the url and cgiurl still matters when a URL must be absolute, such as in an RSS feed.

I improved this code in late 2010 for this todo item: want to avoid ikiwiki using http or https in urls to allow serving both. It's possible that it has regressed (that's happened a couple of times). If it has, please quote your exact url and cgiurl configuration.

Comment by smcv Mon Nov 5 07:27:02 2012

In git master, if $config{html5} = 1 then the <base> URL will usually be host-relative or protocol-relative (/wiki/ or //example.com/wiki/) which reduces the need for that option.

This is not yet available in a release, and is still subject to change.

I still don't know what your wiki's configuration is, because you never told us the settings I asked for (cgiurl and url), so I don't know whether this will help you.

Comment by smcv Sun Oct 5 18:56:56 2014