[erlang-questions] Force HTTP to HTTPS in Yaws

mog mog-lists@REDACTED
Tue Jul 8 23:46:08 CEST 2008

Hash: SHA1

Kimmo Gläborg wrote:
|>> How can I configure Yaws to force https? Like I would like any user
|>> that loads the
|>> site in http, to be redirected to https.
|> One way of doing it would be to change your yaws.conf file to have two
|> docroot directories. One for http and the other one for https.
|> https-docroot would be the one you are currently using. http-docroot
|> would contain index.yaws file only which would always redirect to
|> https. It could look like this (listing of index.yaws):
|> <erl>
|> out(A) ->
|>    {redirect,"https://localhost/"}.
|> </erl>
|> Change the above with your domain. This will however break any
|> functionality that was available through http.
| Thanks Michal! I probably would like to keep the http environment  
| working aswell.
| Isn't there a way to configure this in the Yaws config environment? (I  
| believe this is
| just a setting, both in IIS and Apache for example..)
| // kimmo
| _______________________________________________
| erlang-questions mailing list
| erlang-questions@REDACTED
| http://www.erlang.org/mailman/listinfo/erlang-questions
its pretty easy to get it going the way you want here is https redirect 
i wrote once

- -module(http_redirect).

- -include("/usr/local/lib/yaws/include/yaws_api.hrl").
- -export([out/1]).

~    Path = Args#arg.server_path,
~    Redirect = lists:append("https://www.YOURDOMAINHERE.com", Path),
~    {redirect, Redirect}.

<server redirect>
~        port = 80
~        listen =
~        appmods = <"/", http_redirect>
~        docroot = /usr/local/var/yaws/ebin


hope this helps mog
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the erlang-questions mailing list