Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

A Profound.js server instance can be configured for HTTPS by setting a few options in the instance configuration file. The simplest configuration uses just the sslKey and sslCert configuration options to specify the location of the SSL certificate and private key. In this example, the server is configured to listen on the standard HTTPS port 443:

Code Block
languagejavascript
titleBasic Configuration for HTTPS
module.exports = {
  "port": 443,
  "staticFilesDirectory": "htdocs",
  "pathlist": [
    "pjssamples"
  ],
  "initialModules": {
    "/hello": "pjssamples/hello",
    "/hello2": "pjssamples/hello2",
    "/connect4": "pjssamples/connect4",
    "/upload": "pjssamples/upload"
  },
  "dbDriver": "IBMi",
  "timeout": 3600,
  "sslKey": "/my_cert/key.pem",
  "sslCert": "/my_cert/cert.pem"
}

This example uses the securePort configuration option to configure the server to handle both HTTP (port 80) and HTTPS (port 443):

Code Block
languagejavascript
titleConfiguration for Both HTTP/HTTPS
module.exports = {
  "port": 80,
  "staticFilesDirectory": "htdocs",
  "pathlist": [
    "pjssamples"
  ],
  "initialModules": {
    "/hello": "pjssamples/hello",
    "/hello2": "pjssamples/hello2",
    "/connect4": "pjssamples/connect4",
    "/upload": "pjssamples/upload"
  },
  "dbDriver": "IBMi",
  "timeout": 3600,
  "sslKey": "/my_cert/key.pem",
  "sslCert": "/my_cert/cert.pem",
  "securePort": 443
}

This example uses the securePort and redirectHTTP options to configure the server to handle both HTTP (port 80) and HTTPS (port 443). All HTTP requests will be automatically redirected to HTTPS:

Code Block
languagejavascript
titleConfiguration to Redirect HTTP to HTTPS
module.exports = {
  "port": 80,
  "staticFilesDirectory": "htdocs",
  "pathlist": [
    "pjssamples"
  ],
  "initialModules": {
    "/hello": "pjssamples/hello",
    "/hello2": "pjssamples/hello2",
    "/connect4": "pjssamples/connect4",
    "/upload": "pjssamples/upload"
  },
  "dbDriver": "IBMi",
  "timeout": 3600,
  "sslKey": "/my_cert/key.pem",
  "sslCert": "/my_cert/cert.pem",
  "securePort": 443,
  "redirectHTTP": true
}