Force HTTP to HTTPS in Yaws

View: New views
5 Messages — Rating Filter:   Alert me  

Force HTTP to HTTPS in Yaws

by Kimmo Gläborg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I'm new to the Erlang community and more from a systems administrative  
background
rather than the programming side. Not sure if this would be the right  
place to post the
question but let's see :)

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.

(I already have the https environment running & working).

Regards

Kimmo Gläborg

http://www.linkedin.com/in/glaborg
_______________________________________________
erlang-questions mailing list
erlang-questions@...
http://www.erlang.org/mailman/listinfo/erlang-questions

Re: Force HTTP to HTTPS in Yaws

by Michal Slaski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Kimmo,

> 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.

Hope this helps,
Michal

--
Michal Slaski
http://www.erlang-consulting.com
_______________________________________________
erlang-questions mailing list
erlang-questions@...
http://www.erlang.org/mailman/listinfo/erlang-questions

Re: Force HTTP to HTTPS in Yaws

by Kimmo Gläborg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>> 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@...
http://www.erlang.org/mailman/listinfo/erlang-questions

Re: Force HTTP to HTTPS in Yaws

by mog-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
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@...
| 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

%%%http_redirect.erl%%%-----------------------------------------------------
- -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}.


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

%%%%%-----------

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

iD8DBQFIc+Aeeq+tARrxhnsRAt7PAKCOKRc7nOEuCJt4tyQ7q2GIAJS2ngCdGUxm
ibGbptmFI0sOAIc7i6sYypQ=
=pjFt
-----END PGP SIGNATURE-----

_______________________________________________
erlang-questions mailing list
erlang-questions@...
http://www.erlang.org/mailman/listinfo/erlang-questions

Re: Force HTTP to HTTPS in Yaws

by Claes Wikstrom :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

mog wrote:

> | 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..)

Check man page for yaws.conf

/klacke
_______________________________________________
erlang-questions mailing list
erlang-questions@...
http://www.erlang.org/mailman/listinfo/erlang-questions
LightInTheBox - Buy quality products at wholesale price