I chang htto to https but not working

I create api in adonis frame work. I change to http to https . I configured the ssl certificate but not changing the url? Please help me any one

'use strict'

/*
|--------------------------------------------------------------------------
| Http server
|--------------------------------------------------------------------------
|
| This file bootstrap Adonisjs to start the HTTP server. You are free to
| customize the process of booting the http server.
|
| """ Loading ace commands """
|     At times you may want to load ace commands when starting the HTTP server.
|     Same can be done by chaining `loadCommands()` method after
|
| """ Preloading files """
|     Also you can preload files by calling `preLoad('path/to/file')` method.
|     Make sure to pass relative path from the project root.
*/
const { Ignitor } = require('@adonisjs/ignitor')
const path = require('path')
const https = require('https')
const fs = require('fs')

// Certificate
const options = {
  key: fs.readFileSync(path.join(__dirname, './sslforfree/private.key')),
  cert: fs.readFileSync(path.join(__dirname, './sslforfree/certificate.crt'))
}

new Ignitor(require('@adonisjs/fold'))
  .appRoot(__dirname)
  .fireHttpServer((handler) => {
    console.log('https verification')
    return https.createServer(options, handler)
  })
  .catch(console.error)

1 Like

Have you edited the .env file? as the .env file has the url set to http inside it.

2 Likes

I already configured like this in .env file

APP_URL=https://${HOST}:${PORT}

my port number is 3000 is it fine?

What are you using for the webserver?
as you possibly need to proxy it as it is the case if nginx is being used.
I would recommend looking at

1 Like

i am using apache server, is there any possibilities to add ssl option using port number 2000?

Since you are using Apache I recommend checking out this post which explains how to host NodeJS sites through Apache

2 Likes

Already configured 80 port to my html website, I think virtual host conf file not work in aws ec2.

Let Apache do the reverse proxy AND SSL (HTTPS) it’s a lot easier that way.

https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html

Use Apache as reverse proxy and LetsEncrypt


to manage HTTPS certs for you automatically, then you don’t have to do anything HTTPS related in NodeJS codebase (AdonisJS)

You need to expose ports 80 and 443 (80 for HTTP and 443 for HTTPS) also in AWS security group

AWS EC2 is just a regular (almost) VPS, everything that works on any other VPS provider will work in there, including virtual host conf file. There’s most likely something else going on with Apache config

Also check post that @LordDamionDevil mentioned, it seems to solve your problem :slight_smile:

1 Like
<VirtualHost *:80>
    ServerAdmin www.testinghttps.com
    DocumentRoot "/opt/lampp/htdocs"
    ServerName www.testinghttps.com
    ErrorLog "logs/ote.com-error.log"
    CustomLog "logs/ote.com-access.log" common

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyVia Full

    <Proxy *>
        Require all granted
    </Proxy>
    SSLProxyEngine on
    ProxyPass "/api" http://127.0.0.1:3000/api
    ProxyPassReverse "/api" http://127.0.0.1:3000/api
</VirtualHost>

ssl working for https://testinghttps, but same ssl not working for reserverProxy

This is my sample url

Thank you @LordDamionDevil and @McSneaky. Finally i changed http to https :+1: :+1: :+1: :+1: :pray: :pray: :pray: :pray:

1 Like