parasew/instiki

Redirection to localhost

xaltsc opened this issue · 3 comments

Hey,

I have a freshly new installed instiki on my server which I serve through Caddy using the following rule:

notes.website.com {
        tls mail@website.com
        gzip
        proxy / localhost:2500
}

However, for most of the pages I go to, especially the first configuration page, I get redirected to http://localhost:2500/.... instead of http://notes.website.com/.....

I tried to find a relevant setting for that, but it doesn't appear to exist.

I'm running the latest release.

I am unfamiliar with Caddy, but I have run Instiki behind a reverse-proxy (using Apache). It works fine. In such a setup, Instiki does not know (and is not supposed to know) that it is running behind a reverse-proxy.

Check the HTML source of the page in question. You should find that Instiki has generated relative URLs (of the form '/wiki/show/Foo'). These should work properly in a reverse-proxy situation.

These work, but for instance, when I just go the website.com, I get redirected to http://localhost:2500/lab/show/HomePage instead of http://website.com/lab/show/HomePage

So yeah, Caddy was misconfigured. Changing the rule to the following solves the issue:

notes.website.com {
        tls mail@website.com
        gzip
        proxy / localhost:2500 {
                header_upstream X-Forwarded-Proto {scheme}
		header_upstream X-Forwarded-For {remote}
		header_upstream Host {host}
        }
}

I'm not sure it is a minimal working example, but it works.