Commit e1c0d931 authored by Aral Balkan's avatar Aral Balkan
Browse files

Proxy servers are now supported in production via enable command

parent bed85d3d
......@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [16.2.0] - 2021-04-13
### Added
- Proxy servers are now supported in production. To proxy whatever is running over HTTP and WS at port 8080 at https://your.domain, for example, enable the server using:
```shell
site enable :8080
```
## [16.1.1] - 2021-04-11
### Fixed
......
......@@ -242,7 +242,7 @@ You can also tranfer your key to your other devices manually. You can find the k
#### Proxy server
You can use Site.js as a development-time reverse proxy for HTTP and WebSocket connections. This is useful if you have a web app written in any language that only supports HTTP (not TLS) that you want to deploy securely.
You can use Site.js as a reverse proxy for HTTP and WebSocket connections. This is useful if you have a web app written in any language that only supports HTTP (not TLS) that you want to deploy securely.
For example, the following is a simple HTTP server written in Python 3 (_server.py_) that runs insecurely on port 3000:
......@@ -271,7 +271,6 @@ Then, proxy it securely from https://localhost using:
$ site :3000
```
Again, this is a convenient shortcut. The full form of this command is:
```shell
......@@ -446,6 +445,12 @@ If you also want certificates for the _www_ subdomain, specify it using the `--a
__Note:__ As of 13.0.0, the `enable` will run pre-flight checks and refuse to install the service if the domain name and any aliases you have specified are not reachable. As of 14.1.0, you can use the `--skip-domain-reachability-check` flag to override this behaviour and skip the pre-flight checks. If you use this flag, the server launched by the installed service will also not check for reachability. This is useful if you want to set up a server via a script prior to DNS propagation. Just make sure you haven’t made any typos in any of the domain names as you will not be warned about any mistakes.
__Note:__ As of 16.2.0, you can now also run proxy servers in production. To proxy whatever is running over HTTP and WS on port 8080 at https://your.domain, do:
```shell
$ site enable :8080
```
When the server is enabled, you can also use the following commands:
- `start`: Start server.
......@@ -482,6 +487,13 @@ cd app
npm test
```
Note that if you have a large amount of logs, the logs tests might fail due to a timeout. In this case, try clearing your journalctl logs:
```
journalctl --rotate
journalctl --vacuum-time=1s
```
### Install as global Node.js module
After you install the source and run tests:
......
......@@ -80,7 +80,16 @@ function enable (args) {
// It is a common mistake to start the server in a .dynamic folder (or subfolder)
// or a .hugo folder or subfolder. In these cases, try to recover and do the right thing.
const {pathToServe, absolutePathToServe} = Util.magicallyRewritePathToServeIfNecessary(args.positional[0], _pathToServe)
let pathToServe
let absolutePathToServe
if (args.positional[0].startsWith(':')) {
// This is a proxy server, leave as is.
absolutePathToServe = args.positional[0]
} else {
const paths = Util.magicallyRewritePathToServeIfNecessary(args.positional[0], _pathToServe)
pathToServe = paths.pathToServe
absolutePathToServe = paths.absolutePathToServe
}
// If there are aliases, we will add them to the configuration so they can
// be passed to the serve command when Site.js is started.
......
......@@ -765,7 +765,9 @@ class Site {
// (We need to add the WebSocket (WSS) routes after the server has been created).
endAppConfiguration () {
// Create the file watcher to watch for changes on dynamic and wildcard routes.
this.createFileWatcher()
if (!this.isProxyServer) {
this.createFileWatcher()
}
// If we need to load dynamic routes from a routesJS file, do it now.
if (this.routesJsFile !== undefined) {
......
{
"name": "@small-tech/site.js",
"version": "16.1.1",
"version": "16.2.0",
"description": "Small Web construction set.",
"keywords": [
"web server",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment