user2348668
user2348668

Reputation: 768

Mojolicious over HTTPS

I am using Mojolicious for a web app that requires an encrypted connection, but I don't know how to add SSL support to Mojolicious.

My coworker sent me these: files domain.key, domain-bundle.crt, domain.crt

and my Mojolicious startup looks like this:

sub startup {
my $self = shift;
$self->secrets(['secretphrase']);
$self->config(hypnotoad => {listen => ['http://*:80']});

How can I add HTTPS support without having to use a reverse-proxy

Upvotes: 8

Views: 3157

Answers (2)

Maksym
Maksym

Reputation: 123

sub startup {
my $self = shift;
$self->secrets(['secretphrase']);
$self->config(hypnotoad => {
        listen => ['https://*:443?cert=/path/to/domain.crt&key=/path/to/domain.key&ca=/path/to/domain-bundle.crt']
    });

Replace /path/to/domain-bundle.crt with the actual path to your domain-bundle.crt file

You need to run your mojo app with enough privileges to bind to ports below 1024, or you can use a reverse proxy like Nginx or Apache in front of your mojo app.

Upvotes: -1

user2348668
user2348668

Reputation: 768

Found how to do it:

sub startup {
my $self = shift;
$self->secrets(['secretphrase']);
$self->config(hypnotoad => {
      listen => ['https://*:443?cert=/etc/tls/domain.crt&key=/etc/tls/domain.key']
  });

Upvotes: 13

Related Questions