Easy to configure SSL Web Server
that can be used for development or production
HTTP
requests are redirected to HTTPS
Includes the style-sheet from responsive
start-windows.bat
will start the server for development if you provide no arguments.
This will be on port 443
with a self signed certificate
at https://localhost
# Start for development
./start-windows.bat
# Start for production
./start-windows.bat --cert="your-certificate.pem" --pk="your-private-key.pem"
Show the differences between starting with Git Bash or Command Prompt
Right click and select Open Git Bash Here
in the same folder as start-windows.bat
(recommended)
You can also use the Command Prompt
Portable OpenSSL
will be downloaded temporarily if required to generate keys if you use Command Prompt
Your browser may warn you the certificate is self signed, this is normal.
If you changed the port to something other than 443
or 80
then you have to use https://localhost:PORT/
To use server-ssl.js
in production you will need to provide arguments, they are case sensitive.
Arguments/Flags | Description | Default Value |
---|---|---|
--port= |
Specifies the port number for HTTPS |
443 |
--portHttp= |
Specifies the port number for HTTP that will be redirected | 80 |
--cert= |
Specifies the path to the SSL certificate file. |
"certificate.pem" |
--pk= |
Specifies the path to the private key file associated with the SSL certificate. |
"private-key.pem" |
--site= |
Specifies the directory for the website files | "website" |
--error= |
Specifies the directory for error messages (404,500) | "error" |
--entry= |
Specifies the page to use for the entry point | "index.html" |
--noRedirect |
Specifies that HTTP requests should not be redirected |
not present |
Important
Your Certificate
and Private Key
should be relative to the SSL
folder if you bring your own
./start-windows.bat --cert="your-certificate.pem" --pk="your-private-key.pem"
or
node server-ssl.js --cert="your-certificate.pem" --pk="your-private-key.pem"
Important
Your Certificate
and Private Key
should be relative to the SSL
folder if you bring your own
start-windows.bat
will automatically create a Certificate
and Private Key
when you run it if you don't provide any and none exist
This structure is designed to keep the project organized and maintainable, separating error handling, website content, and server configuration.
/root
│
├── /error
│ ├── 404.html
│ └── 500.html
│
├── /ssl
│ ├── your-private-key.pem
│ └── your-certificate.pem
│
├── /website
│ └── index.html
│
├── node.exe
├── server-ssl.js
└── start-windows.bat
The server is configured to serve custom 404
and 500
error pages.
Currently everything is treated like a Server Error
except for Page Not Found
If you want to add more specific custom error pages, place them in the /error
folder and update server-ssl.js
By default, the server runs on port 443
You can provide a different port as an argument.
./start-windows.bat --port=443 --cert="certificate.pem" --pk="private-key.pem"
You can also set the PORT
env variable in Node.js
or modify server-ssl.js
When you run start-windows.bat
the first time the latest version of node.exe
portable will be downloaded
You can use server-ssl.js
directly if you have a valid certificate
,private key
and Node.js
already installed