How to all users to force https?

Hello guys,
I’m from S.Korea
First, understand my lack of English.

I want to all of connection https…

Now, the https connection works well.
However, the http connection is not working.
To do that, how should I modify my .env and server.js?

const { Ignitor } = require('@adonisjs/ignitor');
const path = require('path');
const https = require('https');
const fs = require('fs');

// Certificate
const options = {
  cert: fs.readFileSync(path.join('/etc/letsencrypt/live/mydomain/', './fullchain.pem')),
  key: fs.readFileSync(path.join('/etc/letsencrypt/live/mydomain/', './privkey.pem'))

new Ignitor(require('@adonisjs/fold'))
  .fireHttpServer((handler) => {
    return https.createServer(options, handler)


HOST= mydomain
PORT= 443

Please help me !!

1 Like

Hi @teddy258,

I only know what I would do with nginx, running it as a proxy server.

  1. Run your Adonis application on or what ever port you want to use, but not 80 or 443

  2. Install nginx

  3. Use it’s proxy service to forward all requests on port 443 to

  4. If any request lands on port 80 forward it to port 443

Here is an example of a site config file in /etc/nginx/sites-enabled/somefile

server {
        listen 443 ssl;
        location / {

        ssl on;
        ssl_certificate /etc/ssl/private/letsencrypt-domain.pem;
        ssl_certificate_key /etc/ssl/private/letsencrypt-domain.key;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

server {
    if ($host = {
        return 301 https://$host$request_uri;

        listen 80;
        return 404;

In this way, you can have multiple Adonis apps running on different ports, and you just create a new nginx config file for each one just changing the domain name that is serving that application.


Thanks you so much for your answer

1 Like