]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/bugs/cgi_redirecting_to_non-https_URL.mdwn
failing test (marked TODO) now present
[git.ikiwiki.info.git] / doc / bugs / cgi_redirecting_to_non-https_URL.mdwn
1 I have a private ikiwiki (3.20170111) which is running on a host that serves HTTP and HTTPS, but ikiwiki is configured for (and only served on) HTTPS:
3     url: https://redacted/phd/
4     cgiurl: https://redacted/phd/cgi
6 However, form submissions from ikiwiki are going to a HTTP URL and thus not being served. Example headers from submitting a comment:
10     Request URL:https://redacted/phd/cgi
11     Request Method:POST
12     Status Code:302 Found
13     Remote Address:redacted:443
14     Referrer Policy:no-referrer-when-downgrade
16 Response Headers
18     HTTP/1.1 302 Found
19     Server: nginx/1.10.3
20     Date: Fri, 08 Dec 2017 11:53:35 GMT
21     Content-Length: 0
22     Connection: keep-alive
23     Status: 302 Found
24     Location: http://redacted/phd/blog/38th_Dec/?updated#comment-bd0549eb2464b5ca0544f68e6c32221e
26 > Your form submission was in fact done successfully. The failing redirection to http is
27 > when ikiwiki follows up the successful edit by redirecting you from the form submission
28 > URL to the updated page, which is done by `IkiWiki::redirect`. --[[smcv]]
30 The CGI is served by lighttpd, but the whole site is front-ended by nginx, which reverse-proxies to lighttpd.
32 ----
34 I think this might be to do with nginx not rewriting POST URLs when reverse-proxying, but I'm not sure why
35 they would be generated in an HTTP form in any case, except perhaps by lighttpd's CGI handler since the back
36 end is HTTP. A workaround is for nginx to redirect any HTTP URI to the HTTPS equivalent. I initially disabled
37 that so as to have the path for letsencrypt negotiation not redirected.-- [[Users/Jon]]
39 > Do you have the `reverse_proxy` option set to 1? (It affects how ikiwiki generates
40 > self-referential URLs).
41 >
42 > Is the connection between nginx and lighttpd http or https?
43 >
44 > I think this is maybe a bug in `IkiWiki::redirect` when used in conjunction with
45 > `reverse_proxy: 1`. I've added a failing test case marked as TODO to `t/relativity.t`,
46 > although I haven't been able to fix the bug yet. The bug I found is that when marked
47 > as behind a reverse proxy, `IkiWiki::redirect` sends `Location: /foo/bar/`, which
48 > your backend web server might be misinterpreting. It should send
49 > `Location: https://redacted/foo/bar/` instead.
50 >
51 > Assuming nginx has a reasonable level of configuration, you can redirect http to https
52 > for the entire server except `/.well-known/acme-challenge/` as a good way to bootstrap
53 > ACME negotiation. --[[smcv]]