glondu / belenios

Verifiable online voting system. This is a mirror of https://gitlab.inria.fr/belenios/belenios
https://www.belenios.org
GNU Affero General Public License v3.0
133 stars 21 forks source link

URL scheme is not preserved in emails #24

Open mefyl opened 4 years ago

mefyl commented 4 years ago

When sending out password emails to the user, the correct hostname / port is preserved even behind a proxy, but it seems to me the scheme is always forced to http.

glondu commented 4 years ago

I think that if you configure ocsigenserver to serve https, then links are in https. For reverse proxy situations (where the connection to ocsigenserver is made in http), there is the <rewrite-prefix> directive: I usually use <rewrite-prefix src="http:" dst="https:"/> (in the <eliom> section).

glondu commented 4 years ago

See also https://github.com/glondu/belenios/issues/22

mefyl commented 4 years ago

Thanks for you help, your solution does indeed work. I did see the documentation but was using <redirect/>, sorry about that.

I think this could be done automatically though: my server is behind a reverse proxy, but the hostname and port are correct, probably thanks to ocsigenserver reading X-Forwarded-Host headers ? This make it work almost out of the box, which is great, but using X-Forwarded-Proto could then autodetermine the protocol too and make it perfect. But this may be an issue in Eliom_uri.make_string_uri rather than Belenios then.

glondu commented 3 years ago

After grep-ing through its codebase, I don't think ocsigenserver reads X-Forwarded-Host (nor does eliom). It may be possible that your reverse-proxy doesn't touch the Host header, which explains why the hostname is correct in absolute links generated by Eliom_uri.make_string_uri. This needs further investigation...