How to configure Bailador to serve content over TLS (HTTPS)?

I enjoyed experimenting with Bailador for some time. It is easy to configure and use for simple HTTP requests, but I would like to serve content via HTTPS.

Some of the methods Requestseem to suggest that HTTPS requests are possible:

method scheme      { $.env<p6w.url-scheme> || 'http' }
method secure      { so self.scheme eq 'https' }

And the headers method:

method headers () {
    return %!headers if %!headers;
    for $.env.keys.grep(rx:i/^[HTTP||CONTENT]/) -> $key {
        my $field = S:i/HTTPS?_// given $key;
        %!headers{$field.uc} = $.env{$key};
    }
    return %!headers;
}

In addition, cookies also have https-related material.

I looked through the documentation and examples showing how / if HTTPS is supported, but so far failed.

So, can I serve content via HTTPS in Bailador? If so, how?

+4
source share
1 answer

" , , - ", SSL . Bailador, , , 5284 . - nginx ( letencrypt):

server {
    listen *:443;
    server_name example.com;

    ssl on;
    ssl_certificate     /etc/letsencrypt/certs/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/certs/example.com/privkey.pem;

    # Optional: only uncomment once you are sure your SSL works!
    #add_header Strict-Transport-Security "max-age=15768000";

    location /.well-known/acme-challenge/ { alias /var/www/letsencrypt/; }
    location / {
        proxy_pass http://127.0.0.1:5284/;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Port 443;
        proxy_set_header X-Forwarded-Host $host;

        # re-write redirects to http as to https
        proxy_redirect http:// https://;
    }
}

http- https:

server {
    listen *:80;
    server_name example.com;

    location /.well-known/acme-challenge/ { alias /var/www/letsencrypt/; }
    location / {
        return 301 https://$server_name$request_uri;
    }
}
+7

Source: https://habr.com/ru/post/1681746/


All Articles