mirror of
https://github.com/edgurgel/httparrot
synced 2025-04-05 08:12:31 -04:00
Serve https too when application is started
This commit is contained in:
parent
cd12a8906e
commit
419b5223c9
5 changed files with 58 additions and 4 deletions
|
@ -23,9 +23,15 @@ defmodule HTTParrot do
|
|||
{'/delay/:n', HTTParrot.DelayedHandler, []},
|
||||
{'/html', :cowboy_static, {:priv_file, :httparrot, "html.html"}} ] }
|
||||
])
|
||||
{:ok, port} = :application.get_env(:httparrot, :port)
|
||||
{:ok, _} = :cowboy.start_http(:http, 100, [port: port], [env: [dispatch: dispatch], onresponse: &prettify_json/4])
|
||||
IO.puts "Starting HTTParrot using on port #{port}"
|
||||
{:ok, http_port} = :application.get_env(:httparrot, :http_port)
|
||||
{:ok, https_port} = :application.get_env(:httparrot, :https_port)
|
||||
{:ok, _} = :cowboy.start_http(:http, 100, [port: http_port],
|
||||
[env: [dispatch: dispatch], onresponse: &prettify_json/4])
|
||||
{:ok, _} = :cowboy.start_https(:https, 100,
|
||||
[port: https_port, cacertfile: "priv/ssl/server-ca.crt",
|
||||
certfile: "priv/ssl/server.crt", keyfile: "priv/ssl/server.key"],
|
||||
[env: [dispatch: dispatch], onresponse: &prettify_json/4])
|
||||
IO.puts "Starting HTTParrot on port #{http_port} and SSL on #{https_port}"
|
||||
HTTParrot.Supervisor.start_link
|
||||
end
|
||||
|
||||
|
|
2
mix.exs
2
mix.exs
|
@ -15,7 +15,7 @@ defmodule Httparrot.Mixfile do
|
|||
:cowboy,
|
||||
:jsex ],
|
||||
mod: { HTTParrot, [] },
|
||||
env: [ port: 8080 ] ]
|
||||
env: [ http_port: 8080, https_port: 8433 ] ]
|
||||
end
|
||||
|
||||
defp deps(:dev) do
|
||||
|
|
16
priv/ssl/server-ca.crt
Normal file
16
priv/ssl/server-ca.crt
Normal file
|
@ -0,0 +1,16 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIICeDCCAeGgAwIBAgIJAOvpU0y2e5J4MA0GCSqGSIb3DQEBBQUAMFUxCzAJBgNV
|
||||
BAYTAlVTMQ4wDAYDVQQIDAVUZXhhczETMBEGA1UECgwKTmluZSBOaW5lczEPMA0G
|
||||
A1UECwwGQ293Ym95MRAwDgYDVQQDDAdST09UIENBMB4XDTEzMDIyODA1MTAwMVoX
|
||||
DTMzMDIyMzA1MTAwMVowVTELMAkGA1UEBhMCVVMxDjAMBgNVBAgMBVRleGFzMRMw
|
||||
EQYDVQQKDApOaW5lIE5pbmVzMQ8wDQYDVQQLDAZDb3dib3kxEDAOBgNVBAMMB1JP
|
||||
T1QgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMzmY7Us06yjyUbpqwPx
|
||||
Iv+xh/g3V7we07ClC9GEYnvr3OQvdA1jFEHccMBUUjRoQ8DPd6uSyK5UkixABs08
|
||||
Tt5B3VsnGKr0DIN+IO4SN2PkmBqIU/BN3KdcwN65YNr3iM0KsKWeFtAZdYx4CakX
|
||||
7REbO0wjK20AH3xSBn3uFGiBAgMBAAGjUDBOMB0GA1UdDgQWBBRKfZ8KF2jlLBDm
|
||||
NL6IuEuGY0pdbzAfBgNVHSMEGDAWgBRKfZ8KF2jlLBDmNL6IuEuGY0pdbzAMBgNV
|
||||
HRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAG1I0kBxXiLkM1b7rl2zPLizREYg
|
||||
1m+ajb6rWzPOBg6TXjv58Be+H4tqoHIL/M/crixew5emftBkuAGjiKMhbIokjvan
|
||||
aPTCV8U6HHvNvz9c68HpESWbd+56cHqfsS5XCKp1OpW5tbL2UQYpFKMP4qmbv3Ea
|
||||
pBfPPmSFMBb1i2AI
|
||||
-----END CERTIFICATE-----
|
17
priv/ssl/server.crt
Normal file
17
priv/ssl/server.crt
Normal file
|
@ -0,0 +1,17 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIICpTCCAg6gAwIBAgIJAOvpU0y2e5J5MA0GCSqGSIb3DQEBBQUAMFUxCzAJBgNV
|
||||
BAYTAlVTMQ4wDAYDVQQIDAVUZXhhczETMBEGA1UECgwKTmluZSBOaW5lczEPMA0G
|
||||
A1UECwwGQ293Ym95MRAwDgYDVQQDDAdST09UIENBMB4XDTEzMDIyODA1MjMzNFoX
|
||||
DTMzMDIyMzA1MjMzNFowVzELMAkGA1UEBhMCVVMxDjAMBgNVBAgMBVRleGFzMRMw
|
||||
EQYDVQQKDApOaW5lIE5pbmVzMQ8wDQYDVQQLDAZDb3dib3kxEjAQBgNVBAMMCWxv
|
||||
Y2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAzbW1GjECzHUc/WST
|
||||
qLiAGqjCNccR5saVS+yoz2SPRhpoyf0/qBrX5BY0tzmgozoTiRfE4wCiVD99Cc+D
|
||||
rp/FM49r4EpZdocIovprmOmv/gwkoj95zaA6PKNn1OdmDp2hwJsX2Zm3kpbGUZTx
|
||||
jDkkccmgUb4EjL7qNHq7saQtivUCAwEAAaN7MHkwCQYDVR0TBAIwADAsBglghkgB
|
||||
hvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYE
|
||||
FB6jTEIWI8T1ckORA4GezbyYxtbvMB8GA1UdIwQYMBaAFEp9nwoXaOUsEOY0voi4
|
||||
S4ZjSl1vMA0GCSqGSIb3DQEBBQUAA4GBACMboVQjrx8u/fk3gl/sR0tbA0Wf/NcS
|
||||
2Dzsy2czndgVUAG4Sqb+hfgn0dqAyUKghRrj3JDcYxYksGPIklDfPzZb7yJ39l16
|
||||
6x5ZiIzhp8CAVdPvRxRznw5rZwaXesryXu1jVSZxTr3MYZdkG6KaAM0t90+YlGLZ
|
||||
UG8fAicx0Bf+
|
||||
-----END CERTIFICATE-----
|
15
priv/ssl/server.key
Normal file
15
priv/ssl/server.key
Normal file
|
@ -0,0 +1,15 @@
|
|||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXQIBAAKBgQDNtbUaMQLMdRz9ZJOouIAaqMI1xxHmxpVL7KjPZI9GGmjJ/T+o
|
||||
GtfkFjS3OaCjOhOJF8TjAKJUP30Jz4Oun8Uzj2vgSll2hwii+muY6a/+DCSiP3nN
|
||||
oDo8o2fU52YOnaHAmxfZmbeSlsZRlPGMOSRxyaBRvgSMvuo0eruxpC2K9QIDAQAB
|
||||
AoGAaD85c/h6bpq7Aj7CBbLaWKhFI3OqwsTITB22vsM7SE+B4zsP02UnG1OVi3UM
|
||||
zytTUxpUkKV1njQ+bYZYOVqGWF4Up8tTqUglHn0FTPok1AIemELWtz3sXvdSHC1T
|
||||
lqvFBAZ9kibn13qGyVOiyCFaMwfOM/05RvV7p3jfUMTWnNECQQDs7yCJZ8Ol8MyH
|
||||
TGZzvkjoN2zg1KwmTbSD1hkP6QAJtPdRuqFbjlEru0/PefgOXsWLRIa3/3v0qw2G
|
||||
xGkV6AXTAkEA3kNbFisqUydjPnZIYv/P6SvPdUimHJEjXbAbfNfzS9dzszrOVJd2
|
||||
XqGH7z5yzjoH3IyaIMW8GnubVzGDSjrHFwJAKSU5vELlygpwKkrNO+pelN0TLlQg
|
||||
dSJnZ8GlZorq88SWcn37iX/EftivenNO7YftvEqxLoDSkOGnnrC7Iw/A+wJBAIEe
|
||||
L/QY72WPJCBNJpAce/PA96vyoE1II3txqwZDjZspdpVQPDz4IFOpEwbxCFC1dYuy
|
||||
Qnd3Z2cbF4r3wIWGz9ECQQCJGNhUNtY+Om1ELdqPcquxE2VRV/pucnvJSTKwyo2C
|
||||
Rvm6H7kFDwPDuN23YnTOlTiho0zzCkclcIukhIVJ+dKz
|
||||
-----END RSA PRIVATE KEY-----
|
Loading…
Add table
Reference in a new issue