I replaced all internal links of an eliom web site to https. Now trying to redirect http requests (main page) to the https version?
Best way is to use a reverse proxy like Nginx. E.g., opam.ocaml.org not redirecting to https · Issue #22 · ocaml/opam.ocaml.org · GitHub
The simplest way is to use redirectmod.
Put this in your config file:
<extension findlib-package="ocsigenserver.ext.redirectmod"/>
And in <host>
section something like:
<redirect fullurl="http://myserver.org/(.*)" dest="https://myserver.org/\1"/>
Thank you @Vincent_Balat.
I tried to use redirectmod
, but I can’t have it work.
In order to simplify my test, I used a <redirect>
tag without regexp (only the http and https urls).
Not sure if I should keep tags for HTTP & HTTPS in the configuration file? (I have both in the conf file)
Not sure if I should use ~https:true when creating my services, before registring them with MY_APP.register. (I did not use them)
As a result, both http and https are currently working. But I can’t have http requests redirected to https.
P.S. Is there any way to have redirectmod emit some output in the log file?
The redirection must be at the beginning of your <host>
section.
Perhaps it’s the cause of your problem?
Ocsigen Server tries all extensions sequentially.
You can try to launch ocsigenserver with option -vvv
to get more logs and understand what happens.
Yes! That was it! my <eliommodule>
and <eliom>
tags where before the <redirect>
one.
To answer myself:
- I had to keep two
<port>
tags (for http and https) - and I used
~https:true
for all of my services (not sure if it’s needed or not…)
Thank you for your help, despite the small amount of information I provided.
https:true
is not necessary. This is only to force some links in http pages to switch to https. But with a redirection of all pages to https, you won’t have any http pages …