summaryrefslogtreecommitdiff
path: root/src/https_server.erl
blob: 47b4465977ebe53b2389fa6828a89e4a23b7accb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-module(https_server).
-export([start/0, stop/1]).

start() ->
    io:format("Starting https server~n"),
    case code:ensure_loaded(jiffy) of
        {module, jiffy} -> ok;
        _ -> io:format("missing jiffy -- please add to load path~n")
    end,
    %% TODO: put this in httpd_props.conf and use that at erlang
    %% start. inets:start(httpd, {proplist_file, "httpd_props.conf"}).
    ServerRoot = "/home/linus/usr/src/ct/catlfish/webroot",
    {ok, Pid} =
        inets:start(httpd, 
                    [{port, 8080},
                     %%{bind_address, {127,0,0,1}},
                     {bind_address, {192, 168, 122, 119}},
                     {server_name, "flimsy.ct.nordu.net"},
                     {server_root, ServerRoot},
                     {document_root, ServerRoot ++ "/docroot"},
                     {modules, [mod_alias, 
                                mod_auth, 
                                mod_esi,   
                                mod_get, 
                                mod_head, 
                                mod_log, 
                                mod_disk_log]},
                     %%{re_write, {"^/ct/v1/(.*)$", "/ct/v1/https_server/\\1"}},
                     {re_write, {"^/ct/v1/(.*)_(.*)$", "/ct/v1/\\1-\\2"}},
                     {erl_script_alias, {"/ct", [v1]}},
                     {erl_script_nocache, true},
                     {error_log, "log/error"},
                     {security_log, "log/security"},
                     {transfer_log, "log/transfer"},
                     %% See ssl(3erl) for SSL options.
                     {socket_type, {essl, [
                                           {certfile, ServerRoot ++ "/certs/webcert.pem"},
                                           {keyfile, ServerRoot ++ "/keys/webkey.pem"},
                                           %%{cacertfile, ServerRoot ++ "/certs/cacert.pem"},
                                           {ciphers, ssl:cipher_suites()},
                                           {verify, verify_none}
                                          ]}}
                    ]),
    Pid.

stop(Pid) ->
    inets:stop(httpd, Pid).