Compare commits
127 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 88d5bbb432 | |||
| 5781204c88 | |||
| 5700522b8a | |||
| e266a5b22e | |||
| c9eef34901 | |||
| da85018206 | |||
| cc54dfcf56 | |||
| 4016a957cf | |||
| 509ee83a15 | |||
| 1b6b2a24f1 | |||
| f18f008f84 | |||
| 9e1ed36def | |||
| 8a35725448 | |||
| 5438f83a40 | |||
| 5c4d5a4a85 | |||
| 1be3f7f388 | |||
| 8c2aa23406 | |||
| d2d4ad70ce | |||
| e3817f92c7 | |||
| 159c043ba6 | |||
| fbdb98c355 | |||
| b81dc319e2 | |||
| eec249d68f | |||
| 0f4a5b0cc1 | |||
| 20c23751a4 | |||
| 6aaae7683b | |||
| 826ae9f157 | |||
| 9dbeef0ed2 | |||
| 53f6daa5d5 | |||
| 9ee5cd2a3d | |||
| 13c27bb71e | |||
| 2be54dd505 | |||
| 2c5af1840e | |||
| e5b75014af | |||
| 82f3b4bd7d | |||
| 4186e77ca0 | |||
| 6a05c0087f | |||
| 4206c9bc8a | |||
| 0aa6966dc1 | |||
| 5bbd773460 | |||
| 2c81f8b492 | |||
| 0fe7d586cf | |||
| a4c8b789ad | |||
| b4378e305a | |||
| 5ff0980908 | |||
| e60257d761 | |||
| e94f0edafb | |||
| c417d96e48 | |||
| c5b1dbb46e | |||
| 893a2e2709 | |||
| 01f0dc6b20 | |||
| 736a42066c | |||
| 44403863d1 | |||
| 5be21fa100 | |||
| 042167c01e | |||
| db38d038ef | |||
| a4d8a46360 | |||
| 84e5c10129 | |||
| 98a2871f08 | |||
| 9bb847210a | |||
| 91d4ba5715 | |||
| 3ee2988964 | |||
| 221f1f6237 | |||
| 0a6fbf588e | |||
| 1a8546af6e | |||
| 9e01bdb8e2 | |||
| 33833fbc6c | |||
| 97b5678fe4 | |||
| 9b96984413 | |||
| 0de412b842 | |||
| 64bcce9e23 | |||
| 390812ec33 | |||
| a672bb920f | |||
| c3fabb6107 | |||
| b4ebdbae47 | |||
| c55d2dcf10 | |||
| 7274d5ea8a | |||
| 1ec733c2a9 | |||
| 3ef14d8ac7 | |||
| f332bf95fe | |||
| 6acad8a306 | |||
| 6ae672f707 | |||
| 3d263e2181 | |||
| 85639f29af | |||
| 85448a21fc | |||
| 3b85c4a37e | |||
| 67dd650dce | |||
| 92eaf5f19a | |||
| fcf9a61b1d | |||
| fbd258a876 | |||
| c65b8fc1af | |||
| b7b588d713 | |||
| 00d672c135 | |||
| 6a1e778b49 | |||
| 4cfb26f62f | |||
| 7ba3ad0b21 | |||
| cd93ec2560 | |||
| ede884930e | |||
| 1049920efd | |||
| b7a34403c5 | |||
| 987e19372a | |||
| 0b97aaee91 | |||
| b87ca1fa03 | |||
| 824f872fa5 | |||
| 80248c77d0 | |||
| f592150646 | |||
| f24652936a | |||
| 79af6c4a68 | |||
| fafc757930 | |||
| ead5e1a7bd | |||
| ad57be180a | |||
| 7cc4ce02c9 | |||
| 70dace595b | |||
| 9b043d0e0d | |||
| 381227406b | |||
| 08d1c292c3 | |||
| 64b0a2deb7 | |||
| 9b661c0ee5 | |||
| 8ca91a48e8 | |||
| 39a5683b9e | |||
| 7967334e7d | |||
| 5a875d1e22 | |||
| 4c68d27b6d | |||
| 1cca4f95bc | |||
| 3cef614bb3 | |||
| c3c2ab776d | |||
|
|
a533fa5de1 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
name: Default (not tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install pnpm and npmci
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
|
||||||
|
- name: Run npm prepare
|
||||||
|
run: npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
||||||
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
name: Default (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm publish
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Code quality
|
||||||
|
run: |
|
||||||
|
npmci command npm install -g typescript
|
||||||
|
npmci npm install
|
||||||
|
|
||||||
|
- name: Trigger
|
||||||
|
run: npmci trigger
|
||||||
|
|
||||||
|
- name: Build docs and upload artifacts
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
pnpm install -g @gitzone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
||||||
23
.gitignore
vendored
23
.gitignore
vendored
@@ -1,5 +1,20 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
nginxconfig/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
docs/
|
public/
|
||||||
.nogit/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
image: hosttoday/ht-docker-node:npmts
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- "apt-get update && apt-get install nginx -y"
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test stable
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
environment: npmjs-com_registry
|
|
||||||
script:
|
|
||||||
- npmci publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"command": "npm test",
|
||||||
|
"name": "Run npm test",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 Task Venture Capital GmbH
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
27
README.md
27
README.md
@@ -1,27 +0,0 @@
|
|||||||
# smartnginx
|
|
||||||
control nginx from node, TypeScript ready
|
|
||||||
|
|
||||||
## Status
|
|
||||||
[](https://gitlab.com/pushrocks/smartnginx/commits/master)
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
* easy reverse configuration
|
|
||||||
* automatic letsencrypt DNS01 challenge based ssl cert generation
|
|
||||||
* automatic nginx process handling zero-downtime config reloading
|
|
||||||
* works in Docker environements
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
We recommend the use of TypeScript! :)
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
import * as smartnginx from "smartnginx";
|
|
||||||
myNginxConfig = new smartnginx.NginxConfig();
|
|
||||||
myNginxZone = new smartnginx.NginxZone({
|
|
||||||
zoneName:"some.example.com",
|
|
||||||
type:"reverseProxy",
|
|
||||||
destination:"192.192.192.192" // some destination IP
|
|
||||||
});
|
|
||||||
myNginxConfig.addZone(myNginxZone); // adds the zone to the config
|
|
||||||
myNginxConfig.deploy(); // deploys the referenced NginxConfig and gracefully reloads it
|
|
||||||
```
|
|
||||||
59
changelog.md
Normal file
59
changelog.md
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-11-27 - 2.0.53 - fix(core)
|
||||||
|
Refactor filesystem usage to smartfs async provider, update dependencies, tests and nginx config paths
|
||||||
|
|
||||||
|
- Replace @push.rocks/smartfile usage with @push.rocks/smartfs and introduce a shared SmartFs instance in plugins
|
||||||
|
- Convert sync file operations to async fs APIs (plugins.fs.file(...).write / plugins.fs.directory(...).create) in SmartNginx and NginxHost
|
||||||
|
- Adjust package.json: update test/build scripts, replace dependencies/devDependencies to new packages (@push.rocks/smartfs, @git.zone/*), and update versions
|
||||||
|
- Update test imports to new tapbundle path and node:path; export default tap.start() and remove unused Qenv instantiation
|
||||||
|
- Update internal path imports to 'node:path' and refactor smartnginx.plugins exports
|
||||||
|
- Change generated nginx certificate/config paths in configs from /mnt/HC_Volume_11396573/... to /mnt/data/... and regenerate default cert files
|
||||||
|
- Remove CI config (.gitlab-ci.yml) from repository
|
||||||
|
|
||||||
|
## 2024-05-29 - 2.0.52 - maintenance
|
||||||
|
Various metadata and TypeScript configuration updates; release 2.0.52.
|
||||||
|
|
||||||
|
- Update package description.
|
||||||
|
- Update tsconfig.
|
||||||
|
- Update npmextra.json (githost) entries across multiple commits.
|
||||||
|
- Release tag for 2.0.52.
|
||||||
|
|
||||||
|
## 2023-07-26 - 2.0.51 - maintenance
|
||||||
|
Org migration and core fixes; release 2.0.51.
|
||||||
|
|
||||||
|
- Switch to new organization scheme.
|
||||||
|
- fix(core): miscellaneous updates.
|
||||||
|
- Release tag for 2.0.51.
|
||||||
|
|
||||||
|
## 2019-01-09..2019-08-20 - 2.0.19..2.0.50 - maintenance (multiple patch releases)
|
||||||
|
Series of incremental patch releases with small fixes and cleanups.
|
||||||
|
|
||||||
|
- Many patch releases across the 2.0.x line (2.0.19 through 2.0.50).
|
||||||
|
- Multiple "fix(core): update" commits addressing internal issues.
|
||||||
|
- CI and cleanup fixes (including 2.0.38 cleanup).
|
||||||
|
- Release tags for each patch.
|
||||||
|
|
||||||
|
## 2018-08-10 - 2.0.0 - breaking
|
||||||
|
Major release and scope / packaging changes.
|
||||||
|
|
||||||
|
- 2.0.0 release with core updates.
|
||||||
|
- BREAKING CHANGE: change scope to @pushrocks (package scope/name changed).
|
||||||
|
- Various CI and core fixes accompanying the major release.
|
||||||
|
|
||||||
|
## 2016-08-03..2016-07-25 - 1.0.6..1.0.0 - release / maintenance
|
||||||
|
1.x series consolidations, dependency updates and interface exports.
|
||||||
|
|
||||||
|
- Update dependencies and types.
|
||||||
|
- Consolidate naming and start exporting interfaces.
|
||||||
|
- Add license.
|
||||||
|
- Release tags for 1.0.0 through 1.0.6.
|
||||||
|
|
||||||
|
## 2016-07-06..2016-07-25 - 0.0.0..0.1.0 - initial development
|
||||||
|
Initial implementation and feature work establishing core functionality.
|
||||||
|
|
||||||
|
- Initial project setup, README and CI added.
|
||||||
|
- Implement nginx communication and child process handling.
|
||||||
|
- Start storing generated configs to filesystem and improve config handling.
|
||||||
|
- Add snippets support and tests; multiple README improvements.
|
||||||
|
- Early releases and version tags (0.0.0 through 0.1.0).
|
||||||
3
dist/index.d.ts
vendored
3
dist/index.d.ts
vendored
@@ -1,3 +0,0 @@
|
|||||||
export { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
|
||||||
export { NginxProcess } from "./smartnginx.classes.nginxprocess";
|
|
||||||
export { NginxZone, zoneTypes } from "./smartnginx.classes.nginxzone";
|
|
||||||
10
dist/index.js
vendored
10
dist/index.js
vendored
@@ -1,10 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
// classes
|
|
||||||
var smartnginx_classes_nginxconfig_1 = require("./smartnginx.classes.nginxconfig");
|
|
||||||
exports.NginxConfig = smartnginx_classes_nginxconfig_1.NginxConfig;
|
|
||||||
var smartnginx_classes_nginxprocess_1 = require("./smartnginx.classes.nginxprocess");
|
|
||||||
exports.NginxProcess = smartnginx_classes_nginxprocess_1.NginxProcess;
|
|
||||||
var smartnginx_classes_nginxzone_1 = require("./smartnginx.classes.nginxzone");
|
|
||||||
exports.NginxZone = smartnginx_classes_nginxzone_1.NginxZone;
|
|
||||||
exports.zoneTypes = smartnginx_classes_nginxzone_1.zoneTypes;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsVUFBVTtBQUNWLCtDQUEwQixrQ0FBa0MsQ0FBQztBQUFyRCxtRUFBcUQ7QUFDN0QsZ0RBQTJCLG1DQUFtQyxDQUFDO0FBQXZELHNFQUF1RDtBQUMvRCw2Q0FBa0MsZ0NBQWdDLENBQUM7QUFBM0QsNkRBQVM7QUFBQyw2REFBaUQifQ==
|
|
||||||
16
dist/smartnginx.classes.nginxconfig.d.ts
vendored
16
dist/smartnginx.classes.nginxconfig.d.ts
vendored
@@ -1,16 +0,0 @@
|
|||||||
/// <reference types="q" />
|
|
||||||
import * as plugins from "./smartnginx.plugins";
|
|
||||||
import { NginxZone } from "./smartnginx.classes.nginxzone";
|
|
||||||
import { NginxProcess } from "./smartnginx.classes.nginxprocess";
|
|
||||||
export declare class NginxConfig {
|
|
||||||
zones: NginxZone[];
|
|
||||||
cert: plugins.cert.Cert;
|
|
||||||
nginxProcess: NginxProcess;
|
|
||||||
isDeployed: boolean;
|
|
||||||
constructor(optionsArg: plugins.cert.ICertConstructorOptions);
|
|
||||||
addZone(zoneArg: NginxZone): void;
|
|
||||||
listZones(): NginxZone[];
|
|
||||||
removeZones(zoneArg: NginxZone): void;
|
|
||||||
clean(): void;
|
|
||||||
deploy(): plugins.q.Promise<{}>;
|
|
||||||
}
|
|
||||||
68
dist/smartnginx.classes.nginxconfig.js
vendored
68
dist/smartnginx.classes.nginxconfig.js
vendored
@@ -1,68 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const plugins = require("./smartnginx.plugins");
|
|
||||||
const paths = require("./smartnginx.paths");
|
|
||||||
const snippets = require("./smartnginx.snippets");
|
|
||||||
const smartnginx_classes_nginxprocess_1 = require("./smartnginx.classes.nginxprocess");
|
|
||||||
let allConfigs = [];
|
|
||||||
class NginxConfig {
|
|
||||||
constructor(optionsArg) {
|
|
||||||
this.zones = [];
|
|
||||||
this.nginxProcess = new smartnginx_classes_nginxprocess_1.NginxProcess(this);
|
|
||||||
this.isDeployed = false;
|
|
||||||
this.cert = new plugins.cert.Cert({
|
|
||||||
cfEmail: optionsArg.cfEmail,
|
|
||||||
cfKey: optionsArg.cfKey,
|
|
||||||
sslDir: paths.nginxCertBase,
|
|
||||||
gitOriginRepo: optionsArg.gitOriginRepo,
|
|
||||||
testMode: optionsArg.testMode
|
|
||||||
});
|
|
||||||
}
|
|
||||||
;
|
|
||||||
// interact with Zones
|
|
||||||
addZone(zoneArg) {
|
|
||||||
this.zones.push(zoneArg);
|
|
||||||
}
|
|
||||||
listZones() {
|
|
||||||
return this.zones;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
removeZones(zoneArg) {
|
|
||||||
}
|
|
||||||
clean() {
|
|
||||||
this.zones = [];
|
|
||||||
}
|
|
||||||
// handle deployment of zones
|
|
||||||
deploy() {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigBase);
|
|
||||||
plugins.smartfile.fs.ensureDirSync(paths.nginxZoneBase);
|
|
||||||
plugins.smartfile.fs.ensureDirSync(paths.nginxCertBase);
|
|
||||||
for (let config of allConfigs) {
|
|
||||||
config.isDeployed = false;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
this.isDeployed = true;
|
|
||||||
// write base config
|
|
||||||
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(), paths.nginxConfFile);
|
|
||||||
// deploy zones
|
|
||||||
let promiseArray = [];
|
|
||||||
for (let zone of this.zones) {
|
|
||||||
let zoneDeployedPromise = zone.deploy(this.cert);
|
|
||||||
zoneDeployedPromise.then(() => {
|
|
||||||
plugins.beautylog.info(`Zone ${zone.zoneName} deployed!`);
|
|
||||||
this.nginxProcess.reloadConfig();
|
|
||||||
});
|
|
||||||
promiseArray.push(zoneDeployedPromise);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
plugins.q.all(promiseArray)
|
|
||||||
.then(() => {
|
|
||||||
done.resolve();
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
}
|
|
||||||
exports.NginxConfig = NginxConfig;
|
|
||||||
;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxzQkFBc0IsQ0FBQyxDQUFBO0FBQ2hELE1BQVksS0FBSyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFDNUMsTUFBWSxRQUFRLFdBQU0sdUJBQXVCLENBQUMsQ0FBQTtBQUVsRCxrREFBNkIsbUNBQW1DLENBQUMsQ0FBQTtBQUNqRSxJQUFJLFVBQVUsR0FBa0IsRUFBRSxDQUFDO0FBRW5DO0lBS0ksWUFBWSxVQUFnRDtRQUo1RCxVQUFLLEdBQWdCLEVBQUUsQ0FBQztRQUV4QixpQkFBWSxHQUFpQixJQUFJLDhDQUFZLENBQUMsSUFBSSxDQUFDLENBQUM7UUFDcEQsZUFBVSxHQUFZLEtBQUssQ0FBQztRQUV4QixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUM7WUFDOUIsT0FBTyxFQUFFLFVBQVUsQ0FBQyxPQUFPO1lBQzNCLEtBQUssRUFBRSxVQUFVLENBQUMsS0FBSztZQUN2QixNQUFNLEVBQUUsS0FBSyxDQUFDLGFBQWE7WUFDM0IsYUFBYSxFQUFFLFVBQVUsQ0FBQyxhQUFhO1lBQ3ZDLFFBQVEsRUFBRSxVQUFVLENBQUMsUUFBUTtTQUNoQyxDQUFDLENBQUM7SUFDUCxDQUFDOztJQUVELHNCQUFzQjtJQUN0QixPQUFPLENBQUMsT0FBa0I7UUFDdEIsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUM7SUFDN0IsQ0FBQztJQUNELFNBQVM7UUFDTCxNQUFNLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQztJQUN0QixDQUFDOztJQUNELFdBQVcsQ0FBQyxPQUFrQjtJQUU5QixDQUFDO0lBQ0QsS0FBSztRQUNELElBQUksQ0FBQyxLQUFLLEdBQUcsRUFBRSxDQUFDO0lBQ3BCLENBQUM7SUFDRCw2QkFBNkI7SUFDN0IsTUFBTTtRQUNGLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDN0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxlQUFlLENBQUMsQ0FBQztRQUMxRCxPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxhQUFhLENBQUMsS0FBSyxDQUFDLGFBQWEsQ0FBQyxDQUFDO1FBQ3hELE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLGFBQWEsQ0FBQyxLQUFLLENBQUMsYUFBYSxDQUFDLENBQUM7UUFDeEQsR0FBRyxDQUFDLENBQUMsSUFBSSxNQUFNLElBQUksVUFBVSxDQUFDLENBQUMsQ0FBQztZQUM1QixNQUFNLENBQUMsVUFBVSxHQUFHLEtBQUssQ0FBQztRQUM5QixDQUFDO1FBQUEsQ0FBQztRQUNGLElBQUksQ0FBQyxVQUFVLEdBQUcsSUFBSSxDQUFDO1FBQ3ZCLG9CQUFvQjtRQUNwQixPQUFPLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQzdCLFFBQVEsQ0FBQyxtQkFBbUIsRUFBRSxFQUM5QixLQUFLLENBQUMsYUFBYSxDQUN0QixDQUFDO1FBQ0YsZUFBZTtRQUNmLElBQUksWUFBWSxHQUFHLEVBQUUsQ0FBQztRQUN0QixHQUFHLENBQUMsQ0FBQyxJQUFJLElBQUksSUFBSSxJQUFJLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQztZQUMxQixJQUFJLG1CQUFtQixHQUFHLElBQUksQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1lBQ2pELG1CQUFtQixDQUFDLElBQUksQ0FBQztnQkFDckIsT0FBTyxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsUUFBUSxJQUFJLENBQUMsUUFBUSxZQUFZLENBQUMsQ0FBQztnQkFDMUQsSUFBSSxDQUFDLFlBQVksQ0FBQyxZQUFZLEVBQUUsQ0FBQztZQUNyQyxDQUFDLENBQUMsQ0FBQztZQUNILFlBQVksQ0FBQyxJQUFJLENBQUMsbUJBQW1CLENBQUMsQ0FBQztRQUMzQyxDQUFDO1FBQUEsQ0FBQztRQUNGLE9BQU8sQ0FBQyxDQUFDLENBQUMsR0FBRyxDQUFDLFlBQVksQ0FBQzthQUN0QixJQUFJLENBQUM7WUFDRixJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDbkIsQ0FBQyxDQUFDLENBQUM7UUFFUCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN4QixDQUFDOztBQUNMLENBQUM7QUE1RFksbUJBQVcsY0E0RHZCLENBQUE7QUFBQSxDQUFDIn0=
|
|
||||||
26
dist/smartnginx.classes.nginxprocess.d.ts
vendored
26
dist/smartnginx.classes.nginxprocess.d.ts
vendored
@@ -1,26 +0,0 @@
|
|||||||
/// <reference types="node" />
|
|
||||||
/// <reference types="q" />
|
|
||||||
import * as plugins from "./smartnginx.plugins";
|
|
||||||
import { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
|
||||||
export declare class NginxProcess {
|
|
||||||
started: boolean;
|
|
||||||
nginxConfig: NginxConfig;
|
|
||||||
nginxChildProcess: plugins.childProcess.ChildProcess;
|
|
||||||
constructor(nginxConfigArg: any);
|
|
||||||
/**
|
|
||||||
* start nginx
|
|
||||||
*/
|
|
||||||
start(): plugins.q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* reload config
|
|
||||||
*/
|
|
||||||
reloadConfig(): plugins.q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* stop the nginx instance
|
|
||||||
*/
|
|
||||||
stop(): plugins.q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* checks if nginx is in path
|
|
||||||
*/
|
|
||||||
check(): boolean;
|
|
||||||
}
|
|
||||||
76
dist/smartnginx.classes.nginxprocess.js
vendored
76
dist/smartnginx.classes.nginxprocess.js
vendored
@@ -1,76 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const plugins = require("./smartnginx.plugins");
|
|
||||||
const paths = require("./smartnginx.paths");
|
|
||||||
class NginxProcess {
|
|
||||||
constructor(nginxConfigArg) {
|
|
||||||
this.started = false;
|
|
||||||
this.nginxConfig = nginxConfigArg;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
/**
|
|
||||||
* start nginx
|
|
||||||
*/
|
|
||||||
start() {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
if (typeof this.nginxChildProcess == "undefined") {
|
|
||||||
this.nginxChildProcess = plugins.childProcess.exec(`nginx -c ${paths.nginxConfFile}`, function (error, stdout, stderr) {
|
|
||||||
console.log(`stdout: ${stdout}`);
|
|
||||||
console.log(`stderr: ${stderr}`);
|
|
||||||
if (error !== null) {
|
|
||||||
console.log(`exec error: ${error}`);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
;
|
|
||||||
this.started = true;
|
|
||||||
plugins.beautylog.info("started Nginx!");
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
/**
|
|
||||||
* reload config
|
|
||||||
*/
|
|
||||||
reloadConfig() {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
if (this.started == false) {
|
|
||||||
this.start();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
plugins.shelljs.exec("nginx -s reload");
|
|
||||||
}
|
|
||||||
;
|
|
||||||
plugins.beautylog.ok("NginxProcess has loaded the new config!");
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
/**
|
|
||||||
* stop the nginx instance
|
|
||||||
*/
|
|
||||||
stop() {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
if (typeof this.nginxChildProcess != "undefined") {
|
|
||||||
plugins.shelljs.exec("nginx -s quit");
|
|
||||||
this.started = false;
|
|
||||||
plugins.beautylog.info("stopped Nginx!");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
plugins.beautylog.log("nginx already stopped!");
|
|
||||||
}
|
|
||||||
;
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
/**
|
|
||||||
* checks if nginx is in path
|
|
||||||
*/
|
|
||||||
check() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
}
|
|
||||||
exports.NginxProcess = NginxProcess;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54cHJvY2Vzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguY2xhc3Nlcy5uZ2lueHByb2Nlc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsTUFBWSxLQUFLLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUk1QztJQUlJLFlBQVksY0FBYztRQUgxQixZQUFPLEdBQVksS0FBSyxDQUFDO1FBSXJCLElBQUksQ0FBQyxXQUFXLEdBQUcsY0FBYyxDQUFDO0lBQ3RDLENBQUM7O0lBRUQ7O09BRUc7SUFDSCxLQUFLO1FBQ0QsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUM3QixFQUFFLENBQUMsQ0FBQyxPQUFPLElBQUksQ0FBQyxpQkFBaUIsSUFBSSxXQUFXLENBQUMsQ0FBQSxDQUFDO1lBQzlDLElBQUksQ0FBQyxpQkFBaUIsR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxZQUFZLEtBQUssQ0FBQyxhQUFhLEVBQUUsRUFBRSxVQUFVLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTTtnQkFDakgsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLE1BQU0sRUFBRSxDQUFDLENBQUM7Z0JBQ2pDLE9BQU8sQ0FBQyxHQUFHLENBQUMsV0FBVyxNQUFNLEVBQUUsQ0FBQyxDQUFDO2dCQUNqQyxFQUFFLENBQUMsQ0FBQyxLQUFLLEtBQUssSUFBSSxDQUFDLENBQUMsQ0FBQztvQkFDakIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLEtBQUssRUFBRSxDQUFDLENBQUM7Z0JBQ3hDLENBQUM7Z0JBQUEsQ0FBQztZQUNOLENBQUMsQ0FBQyxDQUFDO1FBQ1AsQ0FBQztRQUFBLENBQUM7UUFDRixJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQztRQUNwQixPQUFPLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDO1FBQ3pDLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztRQUNmLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7O0lBRUQ7O09BRUc7SUFDSCxZQUFZO1FBQ1IsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUM3QixFQUFFLENBQUEsQ0FBQyxJQUFJLENBQUMsT0FBTyxJQUFJLEtBQUssQ0FBQyxDQUFBLENBQUM7WUFDdEIsSUFBSSxDQUFDLEtBQUssRUFBRSxDQUFBO1FBQ2hCLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGlCQUFpQixDQUFDLENBQUM7UUFDNUMsQ0FBQztRQUFBLENBQUM7UUFDRixPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyx5Q0FBeUMsQ0FBQyxDQUFBO1FBQy9ELElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztRQUNmLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7O0lBRUQ7O09BRUc7SUFDSCxJQUFJO1FBQ0EsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUM3QixFQUFFLENBQUMsQ0FBQyxPQUFPLElBQUksQ0FBQyxpQkFBaUIsSUFBSSxXQUFXLENBQUMsQ0FBQyxDQUFDO1lBQy9DLE9BQU8sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGVBQWUsQ0FBQyxDQUFDO1lBQ3RDLElBQUksQ0FBQyxPQUFPLEdBQUcsS0FBSyxDQUFDO1lBQ3JCLE9BQU8sQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLGdCQUFnQixDQUFDLENBQUM7UUFDN0MsQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ0osT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztRQUNwRCxDQUFDO1FBQUEsQ0FBQztRQUNGLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztRQUNmLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7O0lBRUQ7O09BRUc7SUFDSCxLQUFLO1FBQ0QsTUFBTSxDQUFDO0lBQ1gsQ0FBQzs7QUFDTCxDQUFDO0FBakVZLG9CQUFZLGVBaUV4QixDQUFBIn0=
|
|
||||||
18
dist/smartnginx.classes.nginxzone.d.ts
vendored
18
dist/smartnginx.classes.nginxzone.d.ts
vendored
@@ -1,18 +0,0 @@
|
|||||||
/// <reference types="q" />
|
|
||||||
import * as plugins from "./smartnginx.plugins";
|
|
||||||
export declare enum zoneTypes {
|
|
||||||
reverseProxy = 0,
|
|
||||||
static = 1,
|
|
||||||
}
|
|
||||||
export declare class NginxZone {
|
|
||||||
zoneName: string;
|
|
||||||
type: zoneTypes;
|
|
||||||
destination: string;
|
|
||||||
configString: string;
|
|
||||||
constructor(optionsArg: {
|
|
||||||
zoneName: string;
|
|
||||||
type: zoneTypes;
|
|
||||||
destination: string;
|
|
||||||
});
|
|
||||||
deploy(certInstanceArg: plugins.cert.Cert): plugins.q.Promise<{}>;
|
|
||||||
}
|
|
||||||
32
dist/smartnginx.classes.nginxzone.js
vendored
32
dist/smartnginx.classes.nginxzone.js
vendored
@@ -1,32 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const plugins = require("./smartnginx.plugins");
|
|
||||||
const paths = require("./smartnginx.paths");
|
|
||||||
const snippets = require("./smartnginx.snippets");
|
|
||||||
(function (zoneTypes) {
|
|
||||||
zoneTypes[zoneTypes["reverseProxy"] = 0] = "reverseProxy";
|
|
||||||
zoneTypes[zoneTypes["static"] = 1] = "static";
|
|
||||||
})(exports.zoneTypes || (exports.zoneTypes = {}));
|
|
||||||
var zoneTypes = exports.zoneTypes;
|
|
||||||
class NginxZone {
|
|
||||||
constructor(optionsArg) {
|
|
||||||
this.zoneName = optionsArg.zoneName;
|
|
||||||
this.type = optionsArg.type;
|
|
||||||
this.destination = optionsArg.destination;
|
|
||||||
this.configString = snippets.getZoneConfigString(optionsArg.zoneName, optionsArg.destination);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
deploy(certInstanceArg) {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
let filePath = plugins.path.join(paths.nginxZoneBase, this.zoneName + ".conf");
|
|
||||||
// writeConfig
|
|
||||||
plugins.smartfile.memory.toFsSync(this.configString, filePath);
|
|
||||||
// get cert
|
|
||||||
certInstanceArg.getDomainCert(this.zoneName)
|
|
||||||
.then(done.resolve);
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
}
|
|
||||||
exports.NginxZone = NginxZone;
|
|
||||||
;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54em9uZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguY2xhc3Nlcy5uZ2lueHpvbmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsTUFBWSxLQUFLLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUM1QyxNQUFZLFFBQVEsV0FBTSx1QkFDMUIsQ0FBQyxDQURnRDtBQUNqRCxXQUFZLFNBQVM7SUFDakIseURBQVksQ0FBQTtJQUNaLDZDQUFNLENBQUE7QUFDVixDQUFDLEVBSFcsaUJBQVMsS0FBVCxpQkFBUyxRQUdwQjtBQUhELElBQVksU0FBUyxHQUFULGlCQUdYLENBQUE7QUFFRDtJQUtJLFlBQVksVUFJWDtRQUNHLElBQUksQ0FBQyxRQUFRLEdBQUcsVUFBVSxDQUFDLFFBQVEsQ0FBQztRQUNwQyxJQUFJLENBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQyxJQUFJLENBQUM7UUFDNUIsSUFBSSxDQUFDLFdBQVcsR0FBRyxVQUFVLENBQUMsV0FBVyxDQUFDO1FBQzFDLElBQUksQ0FBQyxZQUFZLEdBQUcsUUFBUSxDQUFDLG1CQUFtQixDQUFDLFVBQVUsQ0FBQyxRQUFRLEVBQUUsVUFBVSxDQUFDLFdBQVcsQ0FBQyxDQUFDO0lBQ2xHLENBQUM7O0lBQ0QsTUFBTSxDQUFDLGVBQWtDO1FBQ3JDLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDN0IsSUFBSSxRQUFRLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLGFBQWEsRUFBRSxJQUFJLENBQUMsUUFBUSxHQUFHLE9BQU8sQ0FBQyxDQUFDO1FBQy9FLGNBQWM7UUFDZCxPQUFPLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFlBQVksRUFBRSxRQUFRLENBQUMsQ0FBQztRQUMvRCxXQUFXO1FBQ1gsZUFBZSxDQUFDLGFBQWEsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDO2FBQ3ZDLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUM7UUFDeEIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQzs7QUFDTCxDQUFDO0FBekJZLGlCQUFTLFlBeUJyQixDQUFBO0FBQUEsQ0FBQyJ9
|
|
||||||
5
dist/smartnginx.paths.d.ts
vendored
5
dist/smartnginx.paths.d.ts
vendored
@@ -1,5 +0,0 @@
|
|||||||
export declare let packageBase: string;
|
|
||||||
export declare let nginxConfigBase: string;
|
|
||||||
export declare let nginxZoneBase: string;
|
|
||||||
export declare let nginxCertBase: string;
|
|
||||||
export declare let nginxConfFile: string;
|
|
||||||
10
dist/smartnginx.paths.js
vendored
10
dist/smartnginx.paths.js
vendored
@@ -1,10 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const plugins = require("./smartnginx.plugins");
|
|
||||||
// directories
|
|
||||||
exports.packageBase = plugins.path.join(__dirname, "../");
|
|
||||||
exports.nginxConfigBase = plugins.path.join(exports.packageBase, "nginxconfig");
|
|
||||||
exports.nginxZoneBase = plugins.path.join(exports.nginxConfigBase, "zones");
|
|
||||||
exports.nginxCertBase = plugins.path.join(exports.nginxConfigBase, "cert");
|
|
||||||
// files
|
|
||||||
exports.nginxConfFile = plugins.path.join(exports.nginxConfigBase, "nginx.conf");
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wYXRocy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbngucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUd6QixDQUFDLENBSDhDO0FBRS9DLGNBQWM7QUFDSCxtQkFBVyxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyxLQUFLLENBQUMsQ0FBQztBQUNqRCx1QkFBZSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLG1CQUFXLEVBQUMsYUFBYSxDQUFDLENBQUM7QUFDL0QscUJBQWEsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyx1QkFBZSxFQUFDLE9BQU8sQ0FBQyxDQUFDO0FBQzNELHFCQUFhLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsdUJBQWUsRUFBQyxNQUFNLENBQUMsQ0FBQztBQUVyRSxRQUFRO0FBQ0cscUJBQWEsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyx1QkFBZSxFQUFDLFlBQVksQ0FBQyxDQUFDIn0=
|
|
||||||
9
dist/smartnginx.plugins.d.ts
vendored
9
dist/smartnginx.plugins.d.ts
vendored
@@ -1,9 +0,0 @@
|
|||||||
import "typings-global";
|
|
||||||
export import beautylog = require("beautylog");
|
|
||||||
export import cert = require("cert");
|
|
||||||
export import childProcess = require("child_process");
|
|
||||||
export import path = require("path");
|
|
||||||
export import q = require("q");
|
|
||||||
export import shelljs = require("shelljs");
|
|
||||||
export import smartfile = require("smartfile");
|
|
||||||
export import smartstring = require("smartstring");
|
|
||||||
11
dist/smartnginx.plugins.js
vendored
11
dist/smartnginx.plugins.js
vendored
@@ -1,11 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
exports.beautylog = require("beautylog");
|
|
||||||
exports.cert = require("cert");
|
|
||||||
exports.childProcess = require("child_process");
|
|
||||||
exports.path = require("path");
|
|
||||||
exports.q = require("q");
|
|
||||||
exports.shelljs = require("shelljs");
|
|
||||||
exports.smartfile = require("smartfile");
|
|
||||||
exports.smartstring = require("smartstring");
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixvQkFBWSxXQUFXLGVBQWUsQ0FBQyxDQUFDO0FBQ3hDLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixTQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDakIsZUFBTyxXQUFXLFNBQVMsQ0FBQyxDQUFDO0FBQzdCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyJ9
|
|
||||||
2
dist/smartnginx.snippets.d.ts
vendored
2
dist/smartnginx.snippets.d.ts
vendored
@@ -1,2 +0,0 @@
|
|||||||
export declare let getBaseConfigString: () => string;
|
|
||||||
export declare let getZoneConfigString: (zoneNameArg: string, destinationIpArg: string) => string;
|
|
||||||
102
dist/smartnginx.snippets.js
vendored
102
dist/smartnginx.snippets.js
vendored
@@ -1,102 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const plugins = require("./smartnginx.plugins");
|
|
||||||
exports.getBaseConfigString = () => {
|
|
||||||
let baseConfig = plugins.smartstring.indent.normalize(`
|
|
||||||
user www-data;
|
|
||||||
worker_processes auto;
|
|
||||||
pid /run/nginx.pid;
|
|
||||||
|
|
||||||
events {
|
|
||||||
worker_connections 768;
|
|
||||||
# multi_accept on;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
server_names_hash_bucket_size 128;
|
|
||||||
|
|
||||||
##
|
|
||||||
# Basic Settings
|
|
||||||
##
|
|
||||||
|
|
||||||
sendfile on;
|
|
||||||
tcp_nopush on;
|
|
||||||
tcp_nodelay on;
|
|
||||||
keepalive_timeout 65;
|
|
||||||
types_hash_max_size 2048;
|
|
||||||
# server_tokens off;
|
|
||||||
|
|
||||||
# server_names_hash_bucket_size 64;
|
|
||||||
# server_name_in_redirect off;
|
|
||||||
|
|
||||||
include /etc/nginx/mime.types;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
|
|
||||||
##
|
|
||||||
# SSL Settings
|
|
||||||
##
|
|
||||||
|
|
||||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
|
|
||||||
ssl_prefer_server_ciphers on;
|
|
||||||
|
|
||||||
##
|
|
||||||
# Logging Settings
|
|
||||||
##
|
|
||||||
|
|
||||||
access_log /var/log/nginx/access.log;
|
|
||||||
error_log /var/log/nginx/error.log;
|
|
||||||
|
|
||||||
##
|
|
||||||
# Gzip Settings
|
|
||||||
##
|
|
||||||
|
|
||||||
gzip on;
|
|
||||||
gzip_disable "msie6";
|
|
||||||
|
|
||||||
# gzip_vary on;
|
|
||||||
# gzip_proxied any;
|
|
||||||
# gzip_comp_level 6;
|
|
||||||
# gzip_buffers 16 8k;
|
|
||||||
# gzip_http_version 1.1;
|
|
||||||
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
|
||||||
|
|
||||||
##
|
|
||||||
# Virtual Host Configs
|
|
||||||
##
|
|
||||||
|
|
||||||
include /etc/nginx/conf.d/*.conf;
|
|
||||||
include /etc/nginx/sites-enabled/*;
|
|
||||||
}
|
|
||||||
daemon off;
|
|
||||||
`);
|
|
||||||
return baseConfig;
|
|
||||||
};
|
|
||||||
exports.getZoneConfigString = (zoneNameArg, destinationIpArg) => {
|
|
||||||
let zoneConfig = plugins.smartstring.indent.normalize(`
|
|
||||||
upstream ${zoneNameArg} {
|
|
||||||
server ${destinationIpArg};
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen *:80 ;
|
|
||||||
server_name ${zoneNameArg};
|
|
||||||
rewrite ^ https://${zoneNameArg}$request_uri? permanent;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen *:443 ssl;
|
|
||||||
server_name ${zoneNameArg};
|
|
||||||
ssl_certificate /LE_CERTS/${zoneNameArg}/fullchain.pem;
|
|
||||||
ssl_certificate_key /LE_CERTS/${zoneNameArg}/privkey.pem;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://${zoneNameArg};
|
|
||||||
include /etc/nginx/proxy_params;
|
|
||||||
}
|
|
||||||
location ~ /\.git {
|
|
||||||
deny all;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`);
|
|
||||||
return zoneConfig;
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5zbmlwcGV0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguc25pcHBldHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDckMsMkJBQW1CLEdBQUc7SUFDaEMsSUFBSSxVQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7RUFrRXJELENBQUMsQ0FBQztJQUNILE1BQU0sQ0FBQyxVQUFVLENBQUM7QUFDbkIsQ0FBQyxDQUFBO0FBR1UsMkJBQW1CLEdBQUcsQ0FBQyxXQUFrQixFQUFDLGdCQUF1QjtJQUMzRSxJQUFJLFVBQVUsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxTQUFTLENBQUM7YUFDMUMsV0FBVztZQUNaLGdCQUFnQjs7Ozs7aUJBS1gsV0FBVzs4QkFDRSxXQUFXOzs7OztpQkFLeEIsV0FBVzsrQkFDRyxXQUFXO21DQUNQLFdBQVc7Ozt3QkFHdEIsV0FBVzs7Ozs7OztFQU9qQyxDQUFDLENBQUM7SUFDSCxNQUFNLENBQUMsVUFBVSxDQUFDO0FBQ25CLENBQUMsQ0FBQyJ9
|
|
||||||
15
nginxconfig/default.private.pem
Normal file
15
nginxconfig/default.private.pem
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIICWwIBAAKBgQCHoQbEbAo/0ZDFU9AkubBRi8FeKdhCFrzK+wXZD9JnEJRa3q6o
|
||||||
|
CI+6H3YLYleGGP8Vkwca8ykz5BX0MrKAlZWpoEpqgm2lVCBKh9mqCG1bN0aPdlwh
|
||||||
|
E24/HZFbeVgyJBvH/7XZJDGlm638dSMoXMmPtwLfq1uTAmHwtHBEqdiLFwIDAQAB
|
||||||
|
AoGAJWXibtD3toc7qx2kPCwzkRi/Ng7FwdtxLWswPp0dQCwTLEdQ06agswqvyw3P
|
||||||
|
4nsMA0/qWqUIDHXtE8vS6p/Uh21aKTYNgHJA4VZdJvh5Zhogq77dtGFyME7T3914
|
||||||
|
isamRo8hxemijJG9oml7y+jW/xnMFhe98dqKf9k0RNI9G1kCQQDHhInM8HEJWnRX
|
||||||
|
ckkhGoel7HlfpTaLYIO7Ls4ErsNmBQjralRZVX1+g4+h4/QLCcOYqihNDgSUZMEt
|
||||||
|
aEC82c4LAkEArgZXP/gaua0tylBwQETOyUip2apVOvArmH9xLL9qTkXueV39skZb
|
||||||
|
36cO9RK7C+HTY4hGNcXDdihxs+Fa4sD6pQJAQc6FZQMpRVyAYxde53xIoYGNxu5H
|
||||||
|
P1FmIacebIz4Bf5DIuK/T3fTHJdoGI2HQNzHluMIx+GHwSo6TS/FqoRsYQJAe/ia
|
||||||
|
aUC20TU0nJ6nCLG72hqAnUZBh0YW2IFZP3ZxJaed1ioGE90Zj/8zoZShWTqb25j1
|
||||||
|
41KqBt+S+ID+vPCa3QJABo8fEGIy/g7M5OB5euLHQLvCvYJDn9YWAryhRedR1B2e
|
||||||
|
zEZOO0qxUJSjMdnYFYG6Na/poM3atnJ4W8pJzOtA4w==
|
||||||
|
-----END RSA PRIVATE KEY-----
|
||||||
6
nginxconfig/default.public.pem
Normal file
6
nginxconfig/default.public.pem
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
-----BEGIN PUBLIC KEY-----
|
||||||
|
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCHoQbEbAo/0ZDFU9AkubBRi8Fe
|
||||||
|
KdhCFrzK+wXZD9JnEJRa3q6oCI+6H3YLYleGGP8Vkwca8ykz5BX0MrKAlZWpoEpq
|
||||||
|
gm2lVCBKh9mqCG1bN0aPdlwhE24/HZFbeVgyJBvH/7XZJDGlm638dSMoXMmPtwLf
|
||||||
|
q1uTAmHwtHBEqdiLFwIDAQAB
|
||||||
|
-----END PUBLIC KEY-----
|
||||||
27
nginxconfig/hosts/default.private.pem
Normal file
27
nginxconfig/hosts/default.private.pem
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEowIBAAKCAQEAuO16Nu4tMkmBqsNWezt3ENqnsbWNUqC+curHyXURaoIH2wQ1
|
||||||
|
6DIZaBIbO/WndNisMy6TnxJtiMVbKGKjkRH4w3qegthIRCKLD3+Yl1ffqpHRz19h
|
||||||
|
kNxVg4HfXRQMfH0Pnvd/4wB7g2mapk8SMwsTuEZ0j/7dAwc0dqw94g+aehgZlvxU
|
||||||
|
DFQjI/4kU9EiheDZ9TPREBMfeIb82zapINekKq5TkN/euWfsfpbZZ6qWZvTX8Neg
|
||||||
|
ulKOtDCCFauXKv2LNqy4jxWQef2XfMT8Jr4Txud3F8zqfexJYq5ywjH07ecsyi7a
|
||||||
|
/ifv7VLNXUEgwI6OFJHYnFZ314S6KlurocQUWQIDAQABAoIBAAIMpnWrBrSa+d5X
|
||||||
|
whB9uX27XITnXKpoAguNfHivvONBrcXGWVl+zkKh3ip4RFIfE7IjXpyQ6vEalD5j
|
||||||
|
zDh4uiWflt3cVFldDUISdmUb1pEYM5YcMN1c/RRujikQ8qK3ExhyLtqh7Eu8GBnR
|
||||||
|
L7rQ6x9ZoBAAtJT4Wr6rIeEmfW16lunOu97mTi/RL//EHQvlBPgyr2sHLee2aPWV
|
||||||
|
jmC4607vV+xNJPC4qd+6HJDjaXi6hNooVDO8jX48RJUVozMRX7i8GIoDotvObVbA
|
||||||
|
SCqlhbWyawzbCX1p5nvtdOZ0muSIDILudifFUzRzBm0sSL0MxIT0s6OYaQuU0moH
|
||||||
|
Q1nOr+UCgYEA94R/MkApusWYjRcNEPPE2cB1QvtoEDdfhPzwzg1xympRzn8gOwin
|
||||||
|
tpJ25H+dYHeIR5TB5GiqKRY/zwqqqiplEQRkIL+aT/mYqM/vSfchm+gVbBYZL7ql
|
||||||
|
FrE9h+i+mf0/GNoRV3VirWjIjTqBW3DQ0KvxBOos9gJCJA6pMD0xQo0CgYEAv0Pf
|
||||||
|
BvZpskgmxdOGlynUbfu9hQWOqbagU6U1dUwzYbO2EYqjxZeJn5974vJ5XlHAHy3R
|
||||||
|
WuVfGjdiNIph+mDiBFK7wUih6dwVUrKf8H1fucsprfmRkaiKnofaefrlWHMnqo45
|
||||||
|
vWAXkQoJpnR7afQmk3lK8geejMIo/M5Wm+VuS/0CgYA25iRwONsImhsj8CDtyaO3
|
||||||
|
yIA5wxlpv15oWNHwYfsDMmHCs1+quFi6nfHQ7J0zcE/B0LTQvIZBZrXwbiU8aPrR
|
||||||
|
s2+h891+L5Y0myov9ah2tBtMRfqAI53KUrWbF3xvG0SLdpKyG08vtzYEXR2j8nne
|
||||||
|
TsS+mlIunoGdDcNo96mdYQKBgDz7B72xjMuBw5LpOQ0zEf6q96bUucKUbpOcpemr
|
||||||
|
DOrGoHMBT+vsv7073QTjqByRVf7a3dfsL6EtLUtxH4Hzp7wXILOkU7M7LzU5rFLB
|
||||||
|
tmaHRteoLWhSYzfeOqMPglXsCSaQyAn//COLHr6KftquNCpqzqFSGpPoR6cqpmR4
|
||||||
|
Bu2FAoGBAN+UVwhXtSYG89pYFw5u4Oa2XwaVciaqGSkXR0Oyb8pBx65AX6Byy1FD
|
||||||
|
6IooFiAkHqDDz2iIPx7mxzTrHBfKcaHsUcgT5aXr720A6/aD6W5PsVdebWoMMTyA
|
||||||
|
OqFdoeXdMWUzCOWQYp6ViD8f0MQydHppOhugEivReRP700C1WVnx
|
||||||
|
-----END RSA PRIVATE KEY-----
|
||||||
19
nginxconfig/hosts/default.public.pem
Normal file
19
nginxconfig/hosts/default.public.pem
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDBDCCAeygAwIBAgIJZid+XT7/NTaWMA0GCSqGSIb3DQEBBQUAMB4xHDAaBgNV
|
||||||
|
BAMTE3NlbGZzaWduZWQuZ2l0LnpvbmUwHhcNMjUxMTI3MTMxMzM0WhcNMjYxMTI3
|
||||||
|
MTMxMzM0WjAeMRwwGgYDVQQDExNzZWxmc2lnbmVkLmdpdC56b25lMIIBIjANBgkq
|
||||||
|
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuO16Nu4tMkmBqsNWezt3ENqnsbWNUqC+
|
||||||
|
curHyXURaoIH2wQ16DIZaBIbO/WndNisMy6TnxJtiMVbKGKjkRH4w3qegthIRCKL
|
||||||
|
D3+Yl1ffqpHRz19hkNxVg4HfXRQMfH0Pnvd/4wB7g2mapk8SMwsTuEZ0j/7dAwc0
|
||||||
|
dqw94g+aehgZlvxUDFQjI/4kU9EiheDZ9TPREBMfeIb82zapINekKq5TkN/euWfs
|
||||||
|
fpbZZ6qWZvTX8NegulKOtDCCFauXKv2LNqy4jxWQef2XfMT8Jr4Txud3F8zqfexJ
|
||||||
|
Yq5ywjH07ecsyi7a/ifv7VLNXUEgwI6OFJHYnFZ314S6KlurocQUWQIDAQABo0Uw
|
||||||
|
QzAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIC9DAmBgNVHREEHzAdhhtodHRwOi8v
|
||||||
|
ZXhhbXBsZS5vcmcvd2ViaWQjbWUwDQYJKoZIhvcNAQEFBQADggEBAH3qUHaBnNn+
|
||||||
|
e1qlZ0gUooJlLXU5tLGR9cVFV1dKuE5yxZhT0qal4A6Vif1mGKYXmHC4q0/atNsQ
|
||||||
|
RBvrbpoVtJxWpb6iIh1L5WWeP5OxqeLwZ8gp2Qj67CkwmccjIS66kkpwHBkBmXU9
|
||||||
|
nRlmGOj9OBHczqE0cp4dW6pCVvRtzC+wTX9oqAdmjyD8S8oo8I2fjCL4pJTPQtbV
|
||||||
|
RlaryWxlxscXYArA7iE9A5Cl5DdJtkOKS48Rbfw3BEQpgL0J4VeF8Lbb+ryk6BbG
|
||||||
|
XXkkH570cIdTs588gdfhkS8T6NIl+1Aicqmf+v6j3MHrzyLK3SZTQ83hoCRAEMfW
|
||||||
|
SPkrHSeL6h8=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
31
nginxconfig/hosts/test100.bleu.de.conf
Normal file
31
nginxconfig/hosts/test100.bleu.de.conf
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
upstream test100.bleu.de {
|
||||||
|
keepalive 100;
|
||||||
|
server 192.192.192.191:3000;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
# The keepalive parameter sets the maximum number of idle keepalive connections
|
||||||
|
# to upstream servers that are preserved in the cache of each worker process. When
|
||||||
|
# this number is exceeded, the least recently used connections are closed.
|
||||||
|
listen *:80 ;
|
||||||
|
server_name test100.bleu.de;
|
||||||
|
rewrite ^ https://test100.bleu.de$request_uri? permanent;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen *:443 ssl;
|
||||||
|
server_name test100.bleu.de;
|
||||||
|
ssl_certificate /mnt/data/lossless/push.rocks/smartnginx/nginxconfig/hosts/test100.bleu.de.public.pem;
|
||||||
|
ssl_certificate_key /mnt/data/lossless/push.rocks/smartnginx/nginxconfig/hosts/test100.bleu.de.private.pem;
|
||||||
|
location / {
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_buffering off;
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_next_upstream error timeout http_404 http_429 http_500 http_502;
|
||||||
|
proxy_next_upstream_tries 5;
|
||||||
|
proxy_pass http://test100.bleu.de;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
nginxconfig/hosts/test100.bleu.de.private.pem
Normal file
1
nginxconfig/hosts/test100.bleu.de.private.pem
Normal file
@@ -0,0 +1 @@
|
|||||||
|
some private
|
||||||
1
nginxconfig/hosts/test100.bleu.de.public.pem
Normal file
1
nginxconfig/hosts/test100.bleu.de.public.pem
Normal file
@@ -0,0 +1 @@
|
|||||||
|
some public
|
||||||
31
nginxconfig/hosts/test102.bleu.de.conf
Normal file
31
nginxconfig/hosts/test102.bleu.de.conf
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
upstream test102.bleu.de {
|
||||||
|
keepalive 100;
|
||||||
|
server 192.192.192.192:3050;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
# The keepalive parameter sets the maximum number of idle keepalive connections
|
||||||
|
# to upstream servers that are preserved in the cache of each worker process. When
|
||||||
|
# this number is exceeded, the least recently used connections are closed.
|
||||||
|
listen *:80 ;
|
||||||
|
server_name test102.bleu.de;
|
||||||
|
rewrite ^ https://test102.bleu.de$request_uri? permanent;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen *:443 ssl;
|
||||||
|
server_name test102.bleu.de;
|
||||||
|
ssl_certificate /mnt/data/lossless/push.rocks/smartnginx/nginxconfig/hosts/test102.bleu.de.public.pem;
|
||||||
|
ssl_certificate_key /mnt/data/lossless/push.rocks/smartnginx/nginxconfig/hosts/test102.bleu.de.private.pem;
|
||||||
|
location / {
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_buffering off;
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_next_upstream error timeout http_404 http_429 http_500 http_502;
|
||||||
|
proxy_next_upstream_tries 5;
|
||||||
|
proxy_pass http://test102.bleu.de;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
nginxconfig/hosts/test102.bleu.de.private.pem
Normal file
1
nginxconfig/hosts/test102.bleu.de.private.pem
Normal file
@@ -0,0 +1 @@
|
|||||||
|
some private
|
||||||
1
nginxconfig/hosts/test102.bleu.de.public.pem
Normal file
1
nginxconfig/hosts/test102.bleu.de.public.pem
Normal file
@@ -0,0 +1 @@
|
|||||||
|
some public
|
||||||
79
nginxconfig/nginx.conf
Normal file
79
nginxconfig/nginx.conf
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
user www-data;
|
||||||
|
worker_processes auto;
|
||||||
|
pid /run/nginx/nginx.pid;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 768;
|
||||||
|
# multi_accept on;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
server_names_hash_bucket_size 128;
|
||||||
|
|
||||||
|
##
|
||||||
|
# Basic Settings
|
||||||
|
##
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
tcp_nopush on;
|
||||||
|
tcp_nodelay on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
types_hash_max_size 2048;
|
||||||
|
# server_tokens off;
|
||||||
|
|
||||||
|
# server_names_hash_bucket_size 64;
|
||||||
|
# server_name_in_redirect off;
|
||||||
|
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
##
|
||||||
|
# SSL Settings
|
||||||
|
##
|
||||||
|
|
||||||
|
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
|
||||||
|
ssl_prefer_server_ciphers on;
|
||||||
|
|
||||||
|
##
|
||||||
|
# Logging Settings
|
||||||
|
##
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log;
|
||||||
|
error_log /var/log/nginx/error.log;
|
||||||
|
|
||||||
|
##
|
||||||
|
# Gzip Settings
|
||||||
|
##
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_disable "msie6";
|
||||||
|
|
||||||
|
# gzip_vary on;
|
||||||
|
# gzip_proxied any;
|
||||||
|
# gzip_comp_level 6;
|
||||||
|
# gzip_buffers 16 8k;
|
||||||
|
# gzip_http_version 1.1;
|
||||||
|
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
|
|
||||||
|
##
|
||||||
|
# Virtual Host Configs
|
||||||
|
##
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen *:80 default_server;
|
||||||
|
server_name selfsigned.git.zone;
|
||||||
|
rewrite ^ https://git.zone redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen *:443 ssl default_server;
|
||||||
|
server_name selfsigned.git.zone;
|
||||||
|
ssl_certificate /mnt/data/lossless/push.rocks/smartnginx/nginxconfig/hosts/default.public.pem;
|
||||||
|
ssl_certificate_key /mnt/data/lossless/push.rocks/smartnginx/nginxconfig/hosts/default.private.pem;
|
||||||
|
rewrite ^ https://git.zone redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
include /mnt/data/lossless/push.rocks/smartnginx/nginxconfig/hosts/*.conf;
|
||||||
|
include /etc/nginx/sites-enabled/*;
|
||||||
|
}
|
||||||
|
daemon off;
|
||||||
29
npmextra.json
Normal file
29
npmextra.json
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"npmdocker": {},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "code.foss.global",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "smartnginx",
|
||||||
|
"description": "A TypeScript library for controlling Nginx from Node.js, with support for generating and managing Nginx configurations dynamically.",
|
||||||
|
"npmPackagename": "@push.rocks/smartnginx",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"nginx",
|
||||||
|
"node.js",
|
||||||
|
"TypeScript",
|
||||||
|
"configuration management",
|
||||||
|
"web server",
|
||||||
|
"reverse proxy",
|
||||||
|
"SSL certificates"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tsdoc": {
|
||||||
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
71
package.json
71
package.json
@@ -1,40 +1,65 @@
|
|||||||
{
|
{
|
||||||
"name": "smartnginx",
|
"name": "@push.rocks/smartnginx",
|
||||||
"version": "1.0.0",
|
"version": "2.0.53",
|
||||||
"description": "control nginx from node, TypeScript ready",
|
"private": false,
|
||||||
"main": "dist/index.js",
|
"description": "A TypeScript library for controlling Nginx from Node.js, with support for generating and managing Nginx configurations dynamically.",
|
||||||
"typings": "dist/index.d.ts",
|
"main": "dist_ts/index.js",
|
||||||
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)",
|
"test": "tstest test/ --verbose",
|
||||||
"cleanTest": "(rm -r nginxconfig)"
|
"cleanTest": "(rm -r nginxconfig) && npm run test",
|
||||||
|
"build": "(tsbuild tsfolders --allowimplicitany)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+ssh://git@gitlab.com/pushrocks/smartnginx.git"
|
"url": "https://code.foss.global/push.rocks/smartnginx.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"nginx"
|
"nginx",
|
||||||
|
"node.js",
|
||||||
|
"TypeScript",
|
||||||
|
"configuration management",
|
||||||
|
"web server",
|
||||||
|
"reverse proxy",
|
||||||
|
"SSL certificates"
|
||||||
],
|
],
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/smartnginx/issues"
|
"url": "https://gitlab.com/pushrocks/smartnginx/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartnginx#README",
|
"homepage": "https://code.foss.global/push.rocks/smartnginx",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/q": "^0.0.27",
|
"@push.rocks/lik": "^6.2.2",
|
||||||
"@types/shelljs": "^0.3.27",
|
"@push.rocks/smartfs": "^1.1.0",
|
||||||
"beautylog": "^5.0.18",
|
"@push.rocks/smartlog": "^3.1.10",
|
||||||
"cert": "1.0.6",
|
"@push.rocks/smartpath": "^6.0.0",
|
||||||
"q": "^1.4.1",
|
"@push.rocks/smartpromise": "^4.2.3",
|
||||||
"shelljs": "^0.7.1",
|
"@push.rocks/smartshell": "^3.3.0",
|
||||||
"smartfile": "^4.0.12",
|
"@push.rocks/smartstring": "^4.1.0",
|
||||||
"smartstring": "^2.0.15"
|
"@push.rocks/smartunique": "^3.0.9",
|
||||||
|
"selfsigned": "^4.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts-g": "^5.2.6",
|
"@git.zone/tsbuild": "^3.1.0",
|
||||||
"qenv": "^1.0.8",
|
"@git.zone/tsrun": "^2.0.0",
|
||||||
"should": "^10.0.0",
|
"@git.zone/tstest": "^3.1.3",
|
||||||
"typings-test": "^1.0.1"
|
"@push.rocks/qenv": "^6.1.3"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
],
|
||||||
|
"type": "module",
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
8315
pnpm-lock.yaml
generated
Normal file
8315
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
267
readme.md
Normal file
267
readme.md
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
# @push.rocks/smartnginx
|
||||||
|
|
||||||
|
Control Nginx programmatically from Node.js with full TypeScript support 🚀
|
||||||
|
|
||||||
|
## Issue Reporting and Security
|
||||||
|
|
||||||
|
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- 🎯 **Dynamic Configuration** - Generate and manage Nginx configs on the fly
|
||||||
|
- 🔒 **SSL/TLS Ready** - Built-in support for SSL certificates with automatic HTTP→HTTPS redirects
|
||||||
|
- 🔄 **Hot Reload** - Apply configuration changes without downtime
|
||||||
|
- 📦 **Zero-Config Defaults** - Self-signed certificates auto-generated for immediate testing
|
||||||
|
- 🎛️ **Reverse Proxy Made Easy** - Set up proxy hosts with a single method call
|
||||||
|
- 🧠 **Smart Diffing** - Only reloads Nginx when configurations actually change
|
||||||
|
- 📝 **TypeScript First** - Full type definitions included
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm add @push.rocks/smartnginx
|
||||||
|
# or
|
||||||
|
npm install @push.rocks/smartnginx
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Prerequisites**: Nginx must be installed and available in your system PATH.
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { SmartNginx } from '@push.rocks/smartnginx';
|
||||||
|
|
||||||
|
// Create a SmartNginx instance with a default fallback URL
|
||||||
|
const nginx = new SmartNginx({
|
||||||
|
defaultProxyUrl: 'https://your-default-site.com'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add a reverse proxy host
|
||||||
|
nginx.addHostCandidate({
|
||||||
|
hostName: 'api.example.com',
|
||||||
|
destination: 'localhost',
|
||||||
|
destinationPort: 3000,
|
||||||
|
privateKey: '<your-ssl-private-key>',
|
||||||
|
publicKey: '<your-ssl-certificate>'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Deploy and start Nginx
|
||||||
|
await nginx.deploy();
|
||||||
|
```
|
||||||
|
|
||||||
|
That's it! Your reverse proxy is now running 🎉
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Creating the SmartNginx Instance
|
||||||
|
|
||||||
|
The `SmartNginx` class is your main interface for managing Nginx:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { SmartNginx } from '@push.rocks/smartnginx';
|
||||||
|
|
||||||
|
const nginx = new SmartNginx({
|
||||||
|
defaultProxyUrl: 'https://fallback.example.com', // Where unmatched requests go
|
||||||
|
logger: myCustomLogger // Optional: pass a @push.rocks/smartlog instance
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Adding Host Configurations
|
||||||
|
|
||||||
|
Each host represents a domain/subdomain with its proxy rules and SSL certificates:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Add a host using addHostCandidate()
|
||||||
|
const myHost = nginx.addHostCandidate({
|
||||||
|
hostName: 'app.example.com', // Domain name
|
||||||
|
destination: '127.0.0.1', // Backend server address
|
||||||
|
destinationPort: 8080, // Backend port
|
||||||
|
privateKey: sslPrivateKeyPem, // SSL private key (PEM format)
|
||||||
|
publicKey: sslCertificatePem // SSL certificate (PEM format)
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Multi-Host Setup
|
||||||
|
|
||||||
|
Run multiple sites through a single Nginx instance:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Production API
|
||||||
|
nginx.addHostCandidate({
|
||||||
|
hostName: 'api.myapp.com',
|
||||||
|
destination: 'localhost',
|
||||||
|
destinationPort: 3000,
|
||||||
|
privateKey: apiPrivateKey,
|
||||||
|
publicKey: apiCertificate
|
||||||
|
});
|
||||||
|
|
||||||
|
// Admin panel
|
||||||
|
nginx.addHostCandidate({
|
||||||
|
hostName: 'admin.myapp.com',
|
||||||
|
destination: 'localhost',
|
||||||
|
destinationPort: 4000,
|
||||||
|
privateKey: adminPrivateKey,
|
||||||
|
publicKey: adminCertificate
|
||||||
|
});
|
||||||
|
|
||||||
|
// Staging environment
|
||||||
|
nginx.addHostCandidate({
|
||||||
|
hostName: 'staging.myapp.com',
|
||||||
|
destination: '192.168.1.100',
|
||||||
|
destinationPort: 8080,
|
||||||
|
privateKey: stagingPrivateKey,
|
||||||
|
publicKey: stagingCertificate
|
||||||
|
});
|
||||||
|
|
||||||
|
// Deploy all at once
|
||||||
|
await nginx.deploy();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Deploying Configurations
|
||||||
|
|
||||||
|
The `deploy()` method is smart about changes:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// First deploy - writes configs and starts Nginx
|
||||||
|
await nginx.deploy();
|
||||||
|
|
||||||
|
// Add more hosts dynamically
|
||||||
|
nginx.addHostCandidate({
|
||||||
|
hostName: 'newsite.example.com',
|
||||||
|
destination: 'localhost',
|
||||||
|
destinationPort: 5000,
|
||||||
|
privateKey: newPrivateKey,
|
||||||
|
publicKey: newCertificate
|
||||||
|
});
|
||||||
|
|
||||||
|
// Second deploy - detects changes, updates configs, hot-reloads Nginx
|
||||||
|
await nginx.deploy();
|
||||||
|
|
||||||
|
// If you call deploy() with no changes, it skips the reload (efficient!)
|
||||||
|
await nginx.deploy(); // → "hosts have not diverged, skipping nginx reload"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Querying Deployed Hosts
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Get all deployed hosts
|
||||||
|
const hosts = await nginx.listDeployedHosts();
|
||||||
|
console.log(`Running ${hosts.length} hosts`);
|
||||||
|
|
||||||
|
// Find a specific host by domain
|
||||||
|
const apiHost = nginx.getDeployedNginxHostByHostName('api.example.com');
|
||||||
|
if (apiHost) {
|
||||||
|
console.log(`API proxying to ${apiHost.destination}:${apiHost.destinationPort}`);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Removing Hosts
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const hostToRemove = nginx.getDeployedNginxHostByHostName('staging.myapp.com');
|
||||||
|
if (hostToRemove) {
|
||||||
|
await nginx.removeDeployedHost(hostToRemove);
|
||||||
|
// Nginx automatically reloaded with updated config
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Stopping Nginx
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Gracefully stop the Nginx process
|
||||||
|
await nginx.stop();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Generated Configuration
|
||||||
|
|
||||||
|
SmartNginx generates production-ready Nginx configurations:
|
||||||
|
|
||||||
|
**For each host, you get:**
|
||||||
|
- HTTP (port 80) → HTTPS (port 443) automatic redirect
|
||||||
|
- Upstream with keepalive connections (100 idle connections)
|
||||||
|
- WebSocket-friendly proxy settings (HTTP/1.1, no buffering)
|
||||||
|
- Proper proxy headers (`X-Real-IP`, `X-Forwarded-For`, `X-Forwarded-Proto`)
|
||||||
|
- Smart failover (`proxy_next_upstream` on errors, timeouts, 404/429/500/502)
|
||||||
|
|
||||||
|
**Default server:**
|
||||||
|
- Self-signed certificate for unmatched domains
|
||||||
|
- Redirects to your configured `defaultProxyUrl`
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────────────────────────────────────────────┐
|
||||||
|
│ SmartNginx │
|
||||||
|
├─────────────────────────────────────────────────────────────┤
|
||||||
|
│ hostCandidates[] → deploy() → deployedHosts[] │
|
||||||
|
│ ↓ │
|
||||||
|
│ NginxProcess │
|
||||||
|
│ (start/reload/stop) │
|
||||||
|
└─────────────────────────────────────────────────────────────┘
|
||||||
|
↓
|
||||||
|
┌─────────────────────────────────────────────────────────────┐
|
||||||
|
│ Generated Files │
|
||||||
|
├─────────────────────────────────────────────────────────────┤
|
||||||
|
│ nginxconfig/ │
|
||||||
|
│ ├── nginx.conf (main config) │
|
||||||
|
│ └── hosts/ │
|
||||||
|
│ ├── default.private.pem (self-signed key) │
|
||||||
|
│ ├── default.public.pem (self-signed cert) │
|
||||||
|
│ ├── api.example.com.conf │
|
||||||
|
│ ├── api.example.com.private.pem │
|
||||||
|
│ └── api.example.com.public.pem │
|
||||||
|
└─────────────────────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
## API Reference
|
||||||
|
|
||||||
|
### SmartNginx
|
||||||
|
|
||||||
|
| Method | Description |
|
||||||
|
|--------|-------------|
|
||||||
|
| `addHostCandidate(config)` | Add a new host configuration |
|
||||||
|
| `deploy()` | Write configs and start/reload Nginx |
|
||||||
|
| `listDeployedHosts()` | Get all currently deployed hosts |
|
||||||
|
| `getDeployedNginxHostByHostName(hostname)` | Find a host by domain name |
|
||||||
|
| `removeDeployedHost(host)` | Remove a host and reload Nginx |
|
||||||
|
| `stop()` | Gracefully stop Nginx |
|
||||||
|
|
||||||
|
### IHostConfig
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface IHostConfig {
|
||||||
|
hostName: string; // Domain name (e.g., 'api.example.com')
|
||||||
|
destination: string; // Backend server IP/hostname
|
||||||
|
destinationPort: number; // Backend port
|
||||||
|
privateKey: string; // SSL private key (PEM)
|
||||||
|
publicKey: string; // SSL certificate (PEM)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### NginxHost
|
||||||
|
|
||||||
|
Each host instance exposes:
|
||||||
|
- `hostName` - The configured domain
|
||||||
|
- `destination` - Backend address
|
||||||
|
- `destinationPort` - Backend port
|
||||||
|
- `configString` - The generated Nginx config (after deploy)
|
||||||
|
- `deploy()` - Write this host's config files
|
||||||
|
|
||||||
|
## License and Legal Information
|
||||||
|
|
||||||
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||||
|
|
||||||
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
2
test/test.d.ts
vendored
2
test/test.d.ts
vendored
@@ -1,2 +0,0 @@
|
|||||||
import "typings-test";
|
|
||||||
import "should";
|
|
||||||
61
test/test.js
61
test/test.js
@@ -1,61 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-test");
|
|
||||||
const path = require("path");
|
|
||||||
require("should");
|
|
||||||
const qenv_1 = require("qenv");
|
|
||||||
const smartnginx = require("../dist/index");
|
|
||||||
// setup environment
|
|
||||||
let testQenv = new qenv_1.Qenv(process.cwd(), path.join(process.cwd(), ".nogit"));
|
|
||||||
describe("smartnginx", function () {
|
|
||||||
let testNginxConfig;
|
|
||||||
let testNginxZone01;
|
|
||||||
let testNginxZone02;
|
|
||||||
describe("NginxZone", function () {
|
|
||||||
it(`"new NginxZone()" should produce an instance of NginxConfig`, function () {
|
|
||||||
testNginxZone01 = new smartnginx.NginxZone({
|
|
||||||
zoneName: "test100.bleu.de",
|
|
||||||
type: smartnginx.zoneTypes.reverseProxy,
|
|
||||||
destination: "192.192.192.191"
|
|
||||||
});
|
|
||||||
testNginxZone02 = new smartnginx.NginxZone({
|
|
||||||
zoneName: "test102.bleu.de",
|
|
||||||
type: smartnginx.zoneTypes.reverseProxy,
|
|
||||||
destination: "192.192.192.192"
|
|
||||||
});
|
|
||||||
testNginxZone01.should.be.instanceof(smartnginx.NginxZone);
|
|
||||||
console.log(testNginxZone01.configString);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe("NginxConfig", function () {
|
|
||||||
this.timeout(10000);
|
|
||||||
it(`"new NginxConfig()" should produce an instance of NginxConfig`, function () {
|
|
||||||
testNginxConfig = new smartnginx.NginxConfig({
|
|
||||||
cfEmail: process.env.CF_EMAIL,
|
|
||||||
cfKey: process.env.CF_KEY,
|
|
||||||
testMode: true
|
|
||||||
});
|
|
||||||
testNginxConfig.should.be.instanceof(smartnginx.NginxConfig);
|
|
||||||
});
|
|
||||||
describe(".addZone()", function () {
|
|
||||||
it("should add a zone to NginxConfig Object", function () {
|
|
||||||
testNginxConfig.addZone(testNginxZone01);
|
|
||||||
testNginxConfig.addZone(testNginxZone02);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe(".deploy()", function () {
|
|
||||||
this.timeout(600000);
|
|
||||||
it("should deploy a config from an instance", function (done) {
|
|
||||||
testNginxConfig.deploy()
|
|
||||||
.then(() => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe(".stop", function () {
|
|
||||||
it("should end the process", function () {
|
|
||||||
testNginxConfig.nginxProcess.stop();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsTUFBTyxJQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDOUIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQix1QkFBbUIsTUFBTSxDQUFDLENBQUE7QUFDMUIsTUFBWSxVQUFVLFdBQU0sZUFBZSxDQUFDLENBQUE7QUFFNUMsb0JBQW9CO0FBQ3BCLElBQUksUUFBUSxHQUFHLElBQUksV0FBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsRUFBQyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsRUFBQyxRQUFRLENBQUMsQ0FBQyxDQUFDO0FBQ3pFLFFBQVEsQ0FBQyxZQUFZLEVBQUM7SUFDbEIsSUFBSSxlQUFzQyxDQUFDO0lBQzNDLElBQUksZUFBb0MsQ0FBQztJQUN6QyxJQUFJLGVBQW9DLENBQUM7SUFDekMsUUFBUSxDQUFDLFdBQVcsRUFBQztRQUNqQixFQUFFLENBQUMsNkRBQTZELEVBQUM7WUFDN0QsZUFBZSxHQUFHLElBQUksVUFBVSxDQUFDLFNBQVMsQ0FBQztnQkFDdkMsUUFBUSxFQUFDLGlCQUFpQjtnQkFDMUIsSUFBSSxFQUFDLFVBQVUsQ0FBQyxTQUFTLENBQUMsWUFBWTtnQkFDdEMsV0FBVyxFQUFDLGlCQUFpQjthQUNoQyxDQUFDLENBQUM7WUFDSCxlQUFlLEdBQUcsSUFBSSxVQUFVLENBQUMsU0FBUyxDQUFDO2dCQUN2QyxRQUFRLEVBQUMsaUJBQWlCO2dCQUMxQixJQUFJLEVBQUMsVUFBVSxDQUFDLFNBQVMsQ0FBQyxZQUFZO2dCQUN0QyxXQUFXLEVBQUMsaUJBQWlCO2FBQ2hDLENBQUMsQ0FBQztZQUNILGVBQWUsQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLENBQUM7WUFDM0QsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUMsWUFBWSxDQUFDLENBQUM7UUFDOUMsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDLENBQUMsQ0FBQztJQUNILFFBQVEsQ0FBQyxhQUFhLEVBQUM7UUFDbkIsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQztRQUNwQixFQUFFLENBQUMsK0RBQStELEVBQUM7WUFDL0QsZUFBZSxHQUFHLElBQUksVUFBVSxDQUFDLFdBQVcsQ0FBQztnQkFDekMsT0FBTyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUTtnQkFDN0IsS0FBSyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTTtnQkFDekIsUUFBUSxFQUFDLElBQUk7YUFDaEIsQ0FBQyxDQUFDO1lBQ0gsZUFBZSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsVUFBVSxDQUFDLFVBQVUsQ0FBQyxXQUFXLENBQUMsQ0FBQztRQUNqRSxDQUFDLENBQUMsQ0FBQztRQUNILFFBQVEsQ0FBQyxZQUFZLEVBQUM7WUFDbEIsRUFBRSxDQUFDLHlDQUF5QyxFQUFDO2dCQUN6QyxlQUFlLENBQUMsT0FBTyxDQUFDLGVBQWUsQ0FBQyxDQUFDO2dCQUN6QyxlQUFlLENBQUMsT0FBTyxDQUFDLGVBQWUsQ0FBQyxDQUFDO1lBQzdDLENBQUMsQ0FBQyxDQUFBO1FBQ04sQ0FBQyxDQUFDLENBQUM7UUFDSCxRQUFRLENBQUMsV0FBVyxFQUFDO1lBQ2pCLElBQUksQ0FBQyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7WUFDckIsRUFBRSxDQUFDLHlDQUF5QyxFQUFDLFVBQVMsSUFBSTtnQkFDdEQsZUFBZSxDQUFDLE1BQU0sRUFBRTtxQkFDbkIsSUFBSSxDQUFDO29CQUNGLElBQUksRUFBRSxDQUFDO2dCQUNYLENBQUMsQ0FBQyxDQUFDO1lBQ1gsQ0FBQyxDQUFDLENBQUE7UUFDTixDQUFDLENBQUMsQ0FBQztRQUNILFFBQVEsQ0FBQyxPQUFPLEVBQUM7WUFDYixFQUFFLENBQUMsd0JBQXdCLEVBQUM7Z0JBQ3hCLGVBQWUsQ0FBQyxZQUFZLENBQUMsSUFBSSxFQUFFLENBQUM7WUFDeEMsQ0FBQyxDQUFDLENBQUE7UUFDTixDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFDO0FBQ1AsQ0FBQyxDQUFDLENBQUMifQ==
|
|
||||||
110
test/test.ts
110
test/test.ts
@@ -1,60 +1,54 @@
|
|||||||
import "typings-test";
|
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||||
import path = require("path");
|
import * as path from 'node:path';
|
||||||
import "should";
|
|
||||||
import {Qenv} from "qenv";
|
|
||||||
import * as smartnginx from "../dist/index";
|
|
||||||
|
|
||||||
// setup environment
|
import { Qenv } from '@push.rocks/qenv';
|
||||||
let testQenv = new Qenv(process.cwd(),path.join(process.cwd(),".nogit"));
|
|
||||||
describe("smartnginx",function(){
|
import * as smartnginx from '../ts/index.js';
|
||||||
let testNginxConfig:smartnginx.NginxConfig;
|
|
||||||
let testNginxZone01:smartnginx.NginxZone;
|
let testSmartNginx: smartnginx.SmartNginx;
|
||||||
let testNginxZone02:smartnginx.NginxZone;
|
let testNginxZone01: smartnginx.NginxHost;
|
||||||
describe("NginxZone",function(){
|
let testNginxZone02: smartnginx.NginxHost;
|
||||||
it(`"new NginxZone()" should produce an instance of NginxConfig`,function(){
|
|
||||||
testNginxZone01 = new smartnginx.NginxZone({
|
tap.test('should create a valid instance of SmartNginx', async () => {
|
||||||
zoneName:"test100.bleu.de",
|
testSmartNginx = new smartnginx.SmartNginx({ defaultProxyUrl: 'https://git.zone' });
|
||||||
type:smartnginx.zoneTypes.reverseProxy,
|
expect(testSmartNginx).toBeInstanceOf(smartnginx.SmartNginx);
|
||||||
destination:"192.192.192.191"
|
|
||||||
});
|
|
||||||
testNginxZone02 = new smartnginx.NginxZone({
|
|
||||||
zoneName:"test102.bleu.de",
|
|
||||||
type:smartnginx.zoneTypes.reverseProxy,
|
|
||||||
destination:"192.192.192.192"
|
|
||||||
});
|
|
||||||
testNginxZone01.should.be.instanceof(smartnginx.NginxZone);
|
|
||||||
console.log(testNginxZone01.configString);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe("NginxConfig",function(){
|
|
||||||
this.timeout(10000);
|
|
||||||
it(`"new NginxConfig()" should produce an instance of NginxConfig`,function(){
|
|
||||||
testNginxConfig = new smartnginx.NginxConfig({
|
|
||||||
cfEmail: process.env.CF_EMAIL,
|
|
||||||
cfKey: process.env.CF_KEY,
|
|
||||||
testMode:true
|
|
||||||
});
|
|
||||||
testNginxConfig.should.be.instanceof(smartnginx.NginxConfig);
|
|
||||||
});
|
|
||||||
describe(".addZone()",function(){
|
|
||||||
it("should add a zone to NginxConfig Object",function(){
|
|
||||||
testNginxConfig.addZone(testNginxZone01);
|
|
||||||
testNginxConfig.addZone(testNginxZone02);
|
|
||||||
})
|
|
||||||
});
|
|
||||||
describe(".deploy()",function(){
|
|
||||||
this.timeout(600000);
|
|
||||||
it("should deploy a config from an instance",function(done){
|
|
||||||
testNginxConfig.deploy()
|
|
||||||
.then(() => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
});
|
|
||||||
describe(".stop",function(){
|
|
||||||
it("should end the process",function(){
|
|
||||||
testNginxConfig.nginxProcess.stop();
|
|
||||||
})
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test(`should produce an instance of NginxConfig`, async () => {
|
||||||
|
testNginxZone01 = new smartnginx.NginxHost(testSmartNginx, {
|
||||||
|
hostName: 'test100.bleu.de',
|
||||||
|
destination: '192.192.192.191',
|
||||||
|
destinationPort: 3000,
|
||||||
|
privateKey: 'some private',
|
||||||
|
publicKey: 'some public',
|
||||||
|
});
|
||||||
|
testNginxZone02 = new smartnginx.NginxHost(testSmartNginx, {
|
||||||
|
hostName: 'test102.bleu.de',
|
||||||
|
destination: '192.192.192.192',
|
||||||
|
destinationPort: 3050,
|
||||||
|
privateKey: 'some private',
|
||||||
|
publicKey: 'some public',
|
||||||
|
});
|
||||||
|
expect(testNginxZone01).toBeInstanceOf(smartnginx.NginxHost);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('.addHostCandidate() should add a zone to NginxConfig Object', async () => {
|
||||||
|
testSmartNginx.addHostCandidate(testNginxZone01);
|
||||||
|
testSmartNginx.addHostCandidate(testNginxZone02);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('.deploy() should deploy a config from an instance', async () => {
|
||||||
|
await testSmartNginx.deploy();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should not redeploy', async () => {
|
||||||
|
testSmartNginx.addHostCandidate(testNginxZone01);
|
||||||
|
testSmartNginx.addHostCandidate(testNginxZone02);
|
||||||
|
await testSmartNginx.deploy();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('.stop() should end the process', async () => {
|
||||||
|
testSmartNginx.nginxProcess.stop();
|
||||||
|
});
|
||||||
|
|
||||||
|
export default tap.start();
|
||||||
|
|||||||
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartnginx',
|
||||||
|
version: '2.0.53',
|
||||||
|
description: 'A TypeScript library for controlling Nginx from Node.js, with support for generating and managing Nginx configurations dynamically.'
|
||||||
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
|
||||||
|
|
||||||
// classes
|
// classes
|
||||||
export {NginxConfig} from "./smartnginx.classes.nginxconfig";
|
export * from './smartnginx.classes.smartnginx.js';
|
||||||
export {NginxProcess} from "./smartnginx.classes.nginxprocess";
|
export * from './smartnginx.classes.nginxprocess.js';
|
||||||
export {NginxZone,zoneTypes} from "./smartnginx.classes.nginxzone";
|
export * from './smartnginx.classes.nginxhost.js';
|
||||||
|
|||||||
7
ts/interfaces/hostconfig.ts
Normal file
7
ts/interfaces/hostconfig.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export interface IHostConfig {
|
||||||
|
hostName: string;
|
||||||
|
destination: string;
|
||||||
|
destinationPort: number;
|
||||||
|
privateKey: string;
|
||||||
|
publicKey: string;
|
||||||
|
}
|
||||||
0
ts/interfaces/index.ts
Normal file
0
ts/interfaces/index.ts
Normal file
@@ -1,68 +0,0 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
|
||||||
import * as paths from "./smartnginx.paths";
|
|
||||||
import * as snippets from "./smartnginx.snippets";
|
|
||||||
import { NginxZone } from "./smartnginx.classes.nginxzone";
|
|
||||||
import { NginxProcess } from "./smartnginx.classes.nginxprocess";
|
|
||||||
let allConfigs: NginxConfig[] = [];
|
|
||||||
|
|
||||||
export class NginxConfig {
|
|
||||||
zones: NginxZone[] = [];
|
|
||||||
cert: plugins.cert.Cert; // the Cert Instance from which the config gets its certificates
|
|
||||||
nginxProcess: NginxProcess = new NginxProcess(this);
|
|
||||||
isDeployed: boolean = false;
|
|
||||||
constructor(optionsArg: plugins.cert.ICertConstructorOptions) {
|
|
||||||
this.cert = new plugins.cert.Cert({
|
|
||||||
cfEmail: optionsArg.cfEmail,
|
|
||||||
cfKey: optionsArg.cfKey,
|
|
||||||
sslDir: paths.nginxCertBase,
|
|
||||||
gitOriginRepo: optionsArg.gitOriginRepo,
|
|
||||||
testMode: optionsArg.testMode
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// interact with Zones
|
|
||||||
addZone(zoneArg: NginxZone){
|
|
||||||
this.zones.push(zoneArg);
|
|
||||||
}
|
|
||||||
listZones(): NginxZone[]{
|
|
||||||
return this.zones;
|
|
||||||
};
|
|
||||||
removeZones(zoneArg: NginxZone) {
|
|
||||||
|
|
||||||
}
|
|
||||||
clean() {
|
|
||||||
this.zones = [];
|
|
||||||
}
|
|
||||||
// handle deployment of zones
|
|
||||||
deploy() {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigBase);
|
|
||||||
plugins.smartfile.fs.ensureDirSync(paths.nginxZoneBase);
|
|
||||||
plugins.smartfile.fs.ensureDirSync(paths.nginxCertBase);
|
|
||||||
for (let config of allConfigs) {
|
|
||||||
config.isDeployed = false;
|
|
||||||
};
|
|
||||||
this.isDeployed = true;
|
|
||||||
// write base config
|
|
||||||
plugins.smartfile.memory.toFsSync(
|
|
||||||
snippets.getBaseConfigString(),
|
|
||||||
paths.nginxConfFile
|
|
||||||
);
|
|
||||||
// deploy zones
|
|
||||||
let promiseArray = [];
|
|
||||||
for (let zone of this.zones) {
|
|
||||||
let zoneDeployedPromise = zone.deploy(this.cert);
|
|
||||||
zoneDeployedPromise.then(() => {
|
|
||||||
plugins.beautylog.info(`Zone ${zone.zoneName} deployed!`);
|
|
||||||
this.nginxProcess.reloadConfig();
|
|
||||||
});
|
|
||||||
promiseArray.push(zoneDeployedPromise);
|
|
||||||
};
|
|
||||||
plugins.q.all(promiseArray)
|
|
||||||
.then(() => {
|
|
||||||
done.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
62
ts/smartnginx.classes.nginxhost.ts
Normal file
62
ts/smartnginx.classes.nginxhost.ts
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import * as plugins from './smartnginx.plugins.js';
|
||||||
|
import * as paths from './smartnginx.paths.js';
|
||||||
|
import * as snippets from './smartnginx.snippets.js';
|
||||||
|
|
||||||
|
import { SmartNginx } from './smartnginx.classes.smartnginx.js';
|
||||||
|
|
||||||
|
import { type IHostConfig } from './interfaces/hostconfig.js';
|
||||||
|
|
||||||
|
export enum hostTypes {
|
||||||
|
reverseProxy,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* manages a single nginx host
|
||||||
|
*/
|
||||||
|
export class NginxHost implements IHostConfig {
|
||||||
|
/**
|
||||||
|
* smartnginxInstance this NginHost belongs to
|
||||||
|
*/
|
||||||
|
public smartnginxInstance: SmartNginx;
|
||||||
|
|
||||||
|
public hostName: string; // the host name e.g. domain name
|
||||||
|
public destination: string;
|
||||||
|
public destinationPort: number;
|
||||||
|
public configString: string; // the actual host config file as string
|
||||||
|
public privateKey: string;
|
||||||
|
public publicKey: string;
|
||||||
|
|
||||||
|
constructor(smartnginxInstanceArg: SmartNginx, optionsArg: IHostConfig) {
|
||||||
|
this.smartnginxInstance = smartnginxInstanceArg;
|
||||||
|
this.hostName = optionsArg.hostName;
|
||||||
|
this.destination = optionsArg.destination;
|
||||||
|
this.destinationPort = optionsArg.destinationPort;
|
||||||
|
this.privateKey = optionsArg.privateKey;
|
||||||
|
this.publicKey = optionsArg.publicKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param certInstanceArg
|
||||||
|
*/
|
||||||
|
public async deploy() {
|
||||||
|
const filePathConfig = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.conf`);
|
||||||
|
const filePathPrivate = plugins.path.join(
|
||||||
|
paths.nginxHostDirPath,
|
||||||
|
`${this.hostName}.private.pem`
|
||||||
|
);
|
||||||
|
const filePathPublic = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.public.pem`);
|
||||||
|
|
||||||
|
// writeConfig
|
||||||
|
this.configString = snippets.getHostConfigString(
|
||||||
|
this.hostName,
|
||||||
|
this.destination,
|
||||||
|
this.destinationPort
|
||||||
|
);
|
||||||
|
await plugins.fs.file(filePathConfig).write(this.configString);
|
||||||
|
|
||||||
|
// write ssl
|
||||||
|
await plugins.fs.file(filePathPrivate).write(this.privateKey);
|
||||||
|
await plugins.fs.file(filePathPublic).write(this.publicKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,71 +1,67 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
import * as plugins from './smartnginx.plugins.js';
|
||||||
import * as paths from "./smartnginx.paths";
|
import * as paths from './smartnginx.paths.js';
|
||||||
import { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
import { SmartNginx } from './smartnginx.classes.smartnginx.js';
|
||||||
import { NginxZone } from "./smartnginx.classes.nginxzone";
|
import { NginxHost } from './smartnginx.classes.nginxhost.js';
|
||||||
|
|
||||||
|
import { ChildProcess } from 'child_process';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* manages a nginxprocess for an NginxConfig
|
||||||
|
*/
|
||||||
export class NginxProcess {
|
export class NginxProcess {
|
||||||
started: boolean = false;
|
public started: boolean = false;
|
||||||
nginxConfig:NginxConfig;
|
public smartNginxRef: SmartNginx;
|
||||||
nginxChildProcess: plugins.childProcess.ChildProcess;
|
private nginxChildProcess: ChildProcess;
|
||||||
constructor(nginxConfigArg) {
|
private smartshellInstance = new plugins.smartshell.Smartshell({
|
||||||
this.nginxConfig = nginxConfigArg;
|
executor: 'bash',
|
||||||
};
|
});
|
||||||
|
|
||||||
/**
|
constructor(nginxRefArg: SmartNginx) {
|
||||||
* start nginx
|
this.smartNginxRef = nginxRefArg;
|
||||||
*/
|
}
|
||||||
start() {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
if (typeof this.nginxChildProcess == "undefined"){
|
|
||||||
this.nginxChildProcess = plugins.childProcess.exec(`nginx -c ${paths.nginxConfFile}`, function (error, stdout, stderr) {
|
|
||||||
console.log(`stdout: ${stdout}`);
|
|
||||||
console.log(`stderr: ${stderr}`);
|
|
||||||
if (error !== null) {
|
|
||||||
console.log(`exec error: ${error}`);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
this.started = true;
|
|
||||||
plugins.beautylog.info("started Nginx!");
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reload config
|
* start nginx
|
||||||
*/
|
*/
|
||||||
reloadConfig(){
|
public async start() {
|
||||||
let done = plugins.q.defer();
|
if (!this.nginxChildProcess) {
|
||||||
if(this.started == false){
|
this.nginxChildProcess = (
|
||||||
this.start()
|
await this.smartshellInstance.execStreaming(`nginx -c ${paths.nginxConfFile}`)
|
||||||
} else {
|
).childProcess;
|
||||||
plugins.shelljs.exec("nginx -s reload");
|
}
|
||||||
};
|
this.started = true;
|
||||||
plugins.beautylog.ok("NginxProcess has loaded the new config!")
|
console.log('info', 'started Nginx!');
|
||||||
done.resolve();
|
}
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* stop the nginx instance
|
* reload config
|
||||||
*/
|
*/
|
||||||
stop() {
|
public async reloadConfig() {
|
||||||
let done = plugins.q.defer();
|
if (!this.started) {
|
||||||
if (typeof this.nginxChildProcess != "undefined") {
|
this.start();
|
||||||
plugins.shelljs.exec("nginx -s quit");
|
} else {
|
||||||
this.started = false;
|
await this.smartshellInstance.exec('nginx -s reload');
|
||||||
plugins.beautylog.info("stopped Nginx!");
|
}
|
||||||
} else {
|
this.smartNginxRef.logger.log('info', 'NginxProcess has loaded the new config!');
|
||||||
plugins.beautylog.log("nginx already stopped!");
|
}
|
||||||
};
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if nginx is in path
|
* stop the nginx instance
|
||||||
*/
|
*/
|
||||||
check(): boolean {
|
public async stop() {
|
||||||
return;
|
if (this.nginxChildProcess) {
|
||||||
};
|
this.smartshellInstance.exec('nginx -s quit');
|
||||||
|
this.started = false;
|
||||||
|
this.smartNginxRef.logger.log('info', 'stopped Nginx!');
|
||||||
|
} else {
|
||||||
|
this.smartNginxRef.logger.log('info', 'nginx already stopped!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* checks if nginx is in path
|
||||||
|
*/
|
||||||
|
public check(): boolean {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
|
||||||
import * as paths from "./smartnginx.paths";
|
|
||||||
import * as snippets from "./smartnginx.snippets"
|
|
||||||
export enum zoneTypes {
|
|
||||||
reverseProxy,
|
|
||||||
static
|
|
||||||
}
|
|
||||||
|
|
||||||
export class NginxZone {
|
|
||||||
zoneName: string; // the zone name e.g. domain name
|
|
||||||
type: zoneTypes;
|
|
||||||
destination: string;
|
|
||||||
configString: string; // the actual zone config file as string
|
|
||||||
constructor(optionsArg: {
|
|
||||||
zoneName: string,
|
|
||||||
type: zoneTypes,
|
|
||||||
destination: string
|
|
||||||
}) {
|
|
||||||
this.zoneName = optionsArg.zoneName;
|
|
||||||
this.type = optionsArg.type;
|
|
||||||
this.destination = optionsArg.destination;
|
|
||||||
this.configString = snippets.getZoneConfigString(optionsArg.zoneName, optionsArg.destination);
|
|
||||||
};
|
|
||||||
deploy(certInstanceArg: plugins.cert.Cert) {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
let filePath = plugins.path.join(paths.nginxZoneBase, this.zoneName + ".conf");
|
|
||||||
// writeConfig
|
|
||||||
plugins.smartfile.memory.toFsSync(this.configString, filePath);
|
|
||||||
// get cert
|
|
||||||
certInstanceArg.getDomainCert(this.zoneName)
|
|
||||||
.then(done.resolve);
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
157
ts/smartnginx.classes.smartnginx.ts
Normal file
157
ts/smartnginx.classes.smartnginx.ts
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
import * as plugins from './smartnginx.plugins.js';
|
||||||
|
import * as paths from './smartnginx.paths.js';
|
||||||
|
import * as snippets from './smartnginx.snippets.js';
|
||||||
|
import { NginxHost } from './smartnginx.classes.nginxhost.js';
|
||||||
|
import { NginxProcess } from './smartnginx.classes.nginxprocess.js';
|
||||||
|
import { type IHostConfig } from './interfaces/hostconfig.js';
|
||||||
|
|
||||||
|
export interface ISmartNginxContructorOptions {
|
||||||
|
logger?: plugins.smartlog.Smartlog;
|
||||||
|
defaultProxyUrl: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* main class that manages a NginxInstance
|
||||||
|
*/
|
||||||
|
export class SmartNginx {
|
||||||
|
public options: ISmartNginxContructorOptions;
|
||||||
|
public logger: plugins.smartlog.Smartlog;
|
||||||
|
|
||||||
|
// the objectmaps
|
||||||
|
private deployedHosts = new plugins.lik.ObjectMap<NginxHost>();
|
||||||
|
private hostCandidates = new plugins.lik.ObjectMap<NginxHost>();
|
||||||
|
|
||||||
|
public nginxProcess: NginxProcess = new NginxProcess(this);
|
||||||
|
constructor(optionsArg: ISmartNginxContructorOptions) {
|
||||||
|
this.options = optionsArg;
|
||||||
|
this.options.logger
|
||||||
|
? (this.logger = this.options.logger)
|
||||||
|
: (this.logger = new plugins.smartlog.Smartlog({
|
||||||
|
logContext: null
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================
|
||||||
|
// interact with Hosts
|
||||||
|
// ===================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add a host
|
||||||
|
* @param nginxHostArg
|
||||||
|
*/
|
||||||
|
public addHostCandidate(optionsArg: IHostConfig): NginxHost {
|
||||||
|
const nginxHost = new NginxHost(this, optionsArg);
|
||||||
|
this.hostCandidates.add(nginxHost);
|
||||||
|
return nginxHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a NginxHost by hostname
|
||||||
|
* @param hostNameArg
|
||||||
|
*/
|
||||||
|
public getDeployedNginxHostByHostName(hostNameArg: string): NginxHost {
|
||||||
|
return this.deployedHosts.findSync((nginxHost) => {
|
||||||
|
return nginxHost.hostName === hostNameArg;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* listHosts
|
||||||
|
*/
|
||||||
|
public async listDeployedHosts(): Promise<NginxHost[]> {
|
||||||
|
return this.deployedHosts.getArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* remove a Host
|
||||||
|
* @param nginxHostArg
|
||||||
|
*/
|
||||||
|
public async removeDeployedHost(nginxHostArg: NginxHost) {
|
||||||
|
if (this.hostCandidates.isEmpty()) {
|
||||||
|
this.deployedHosts.forEach((hostArg) => {
|
||||||
|
this.hostCandidates.add(hostArg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.hostCandidates.remove(nginxHostArg);
|
||||||
|
this.deploy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check wether there has been a diverging host configuration
|
||||||
|
* this function will only redeploy the nginx configuration in case there has been a change
|
||||||
|
*/
|
||||||
|
private async areHostsDiverged(): Promise<boolean> {
|
||||||
|
let hostCounter = 0;
|
||||||
|
let unfoundHosts = 0;
|
||||||
|
await this.hostCandidates.forEach(async (hostCandidateArg) => {
|
||||||
|
let foundHost = false;
|
||||||
|
await this.deployedHosts.forEach(async (deployedHostArg) => {
|
||||||
|
if (
|
||||||
|
hostCandidateArg.hostName === deployedHostArg.hostName &&
|
||||||
|
hostCandidateArg.destination === deployedHostArg.destination &&
|
||||||
|
hostCandidateArg.destinationPort === deployedHostArg.destinationPort
|
||||||
|
) {
|
||||||
|
hostCounter++;
|
||||||
|
foundHost = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!foundHost) {
|
||||||
|
unfoundHosts++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
this.deployedHosts.getArray().length !== this.hostCandidates.getArray().length ||
|
||||||
|
hostCounter !== this.deployedHosts.getArray().length ||
|
||||||
|
unfoundHosts !== 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deploy the current stack and restart nginx
|
||||||
|
*/
|
||||||
|
public async deploy() {
|
||||||
|
if (await this.areHostsDiverged()) {
|
||||||
|
this.logger.log('ok', `hosts have diverged, trigger config deployment and nginx reload!`);
|
||||||
|
this.deployedHosts.wipe();
|
||||||
|
this.deployedHosts.addArray(this.hostCandidates.getArray());
|
||||||
|
this.hostCandidates.wipe();
|
||||||
|
|
||||||
|
// write base config
|
||||||
|
await plugins.fs.directory(paths.nginxConfigDirPath).recursive().create();
|
||||||
|
await plugins.fs.file(paths.nginxConfFile).write(
|
||||||
|
snippets.getBaseConfigString(this.options.defaultProxyUrl)
|
||||||
|
);
|
||||||
|
|
||||||
|
// write standard self signed certificate
|
||||||
|
const selfsignedCert = plugins.selfsigned.generate(
|
||||||
|
[{ name: 'commonName', value: 'selfsigned.git.zone' }],
|
||||||
|
{ days: 365 }
|
||||||
|
);
|
||||||
|
|
||||||
|
// deploy hosts
|
||||||
|
await plugins.fs.directory(paths.nginxHostDirPath).recursive().create();
|
||||||
|
await plugins.fs.file(
|
||||||
|
plugins.path.join(paths.nginxHostDirPath, './default.private.pem')
|
||||||
|
).write(selfsignedCert.private);
|
||||||
|
await plugins.fs.file(
|
||||||
|
plugins.path.join(paths.nginxHostDirPath, './default.public.pem')
|
||||||
|
).write(selfsignedCert.cert);
|
||||||
|
for (const host of this.deployedHosts.getArray()) {
|
||||||
|
await host.deploy();
|
||||||
|
this.logger.log('info', `Host ${host.hostName} deployed!`);
|
||||||
|
}
|
||||||
|
this.nginxProcess.reloadConfig();
|
||||||
|
} else {
|
||||||
|
this.logger.log('info', `hosts have not diverged, skipping nginx reload`);
|
||||||
|
this.hostCandidates.wipe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stops the smartnginx instance
|
||||||
|
*/
|
||||||
|
public async stop() {
|
||||||
|
if (this.nginxProcess) {
|
||||||
|
await this.nginxProcess.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
import * as plugins from "./smartnginx.plugins"
|
import * as plugins from './smartnginx.plugins.js';
|
||||||
|
|
||||||
// directories
|
// directories
|
||||||
export let packageBase = plugins.path.join(__dirname,"../");
|
export const packageBase = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
||||||
export let nginxConfigBase = plugins.path.join(packageBase,"nginxconfig");
|
export const nginxConfigDirPath = plugins.path.join(packageBase, 'nginxconfig');
|
||||||
export let nginxZoneBase = plugins.path.join(nginxConfigBase,"zones");
|
export const nginxHostDirPath = plugins.path.join(nginxConfigDirPath, 'hosts');
|
||||||
export let nginxCertBase = plugins.path.join(nginxConfigBase,"cert");
|
|
||||||
|
|
||||||
// files
|
// files
|
||||||
export let nginxConfFile = plugins.path.join(nginxConfigBase,"nginx.conf");
|
export const nginxConfFile = plugins.path.join(nginxConfigDirPath, 'nginx.conf');
|
||||||
|
|||||||
@@ -1,9 +1,25 @@
|
|||||||
import "typings-global";
|
// native
|
||||||
export import beautylog = require("beautylog");
|
import * as path from 'node:path';
|
||||||
export import cert = require("cert");
|
|
||||||
export import childProcess = require("child_process");
|
export { path };
|
||||||
export import path = require("path");
|
|
||||||
export import q = require("q");
|
// @push.rocks scope
|
||||||
export import shelljs = require("shelljs");
|
import * as lik from '@push.rocks/lik';
|
||||||
export import smartfile = require("smartfile");
|
import * as smartfs from '@push.rocks/smartfs';
|
||||||
export import smartstring = require("smartstring");
|
import * as smartlog from '@push.rocks/smartlog';
|
||||||
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
|
import * as smartshell from '@push.rocks/smartshell';
|
||||||
|
import * as smartstring from '@push.rocks/smartstring';
|
||||||
|
import * as smartunique from '@push.rocks/smartunique';
|
||||||
|
|
||||||
|
export { lik, smartfs, smartlog, smartpath, smartpromise, smartshell, smartstring, smartunique };
|
||||||
|
|
||||||
|
// Shared filesystem instance
|
||||||
|
const fsProvider = new smartfs.SmartFsProviderNode();
|
||||||
|
export const fs = new smartfs.SmartFs(fsProvider);
|
||||||
|
|
||||||
|
// thirdparty scope
|
||||||
|
import * as selfsigned from 'selfsigned';
|
||||||
|
|
||||||
|
export { selfsigned };
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
import * as plugins from './smartnginx.plugins.js';
|
||||||
export let getBaseConfigString = () => {
|
import * as paths from './smartnginx.paths.js';
|
||||||
let baseConfig = plugins.smartstring.indent.normalize(`
|
export let getBaseConfigString = (defaultProxy: string) => {
|
||||||
|
const baseConfig = plugins.smartstring.indent.normalize(`
|
||||||
user www-data;
|
user www-data;
|
||||||
worker_processes auto;
|
worker_processes auto;
|
||||||
pid /run/nginx.pid;
|
pid /run/nginx/nginx.pid;
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections 768;
|
worker_connections 768;
|
||||||
@@ -62,42 +63,65 @@ export let getBaseConfigString = () => {
|
|||||||
# Virtual Host Configs
|
# Virtual Host Configs
|
||||||
##
|
##
|
||||||
|
|
||||||
include /etc/nginx/conf.d/*.conf;
|
server {
|
||||||
|
listen *:80 default_server;
|
||||||
|
server_name selfsigned.git.zone;
|
||||||
|
rewrite ^ ${defaultProxy} redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen *:443 ssl default_server;
|
||||||
|
server_name selfsigned.git.zone;
|
||||||
|
ssl_certificate ${paths.nginxHostDirPath}/default.public.pem;
|
||||||
|
ssl_certificate_key ${paths.nginxHostDirPath}/default.private.pem;
|
||||||
|
rewrite ^ ${defaultProxy} redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
include ${paths.nginxHostDirPath}/*.conf;
|
||||||
include /etc/nginx/sites-enabled/*;
|
include /etc/nginx/sites-enabled/*;
|
||||||
}
|
}
|
||||||
daemon off;
|
daemon off;
|
||||||
`);
|
`);
|
||||||
return baseConfig;
|
return baseConfig;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export let getHostConfigString = (
|
||||||
export let getZoneConfigString = (zoneNameArg:string,destinationIpArg:string) => {
|
hostNameArg: string,
|
||||||
let zoneConfig = plugins.smartstring.indent.normalize(`
|
destinationIpArg: string,
|
||||||
upstream ${zoneNameArg} {
|
destinationPortArg = 80
|
||||||
server ${destinationIpArg};
|
) => {
|
||||||
|
const hostConfig = plugins.smartstring.indent.normalize(`
|
||||||
|
upstream ${hostNameArg} {
|
||||||
|
keepalive 100;
|
||||||
|
server ${destinationIpArg}:${destinationPortArg};
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
|
# The keepalive parameter sets the maximum number of idle keepalive connections
|
||||||
|
# to upstream servers that are preserved in the cache of each worker process. When
|
||||||
|
# this number is exceeded, the least recently used connections are closed.
|
||||||
listen *:80 ;
|
listen *:80 ;
|
||||||
server_name ${zoneNameArg};
|
server_name ${hostNameArg};
|
||||||
rewrite ^ https://${zoneNameArg}$request_uri? permanent;
|
rewrite ^ https://${hostNameArg}$request_uri? permanent;
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen *:443 ssl;
|
listen *:443 ssl;
|
||||||
server_name ${zoneNameArg};
|
server_name ${hostNameArg};
|
||||||
ssl_certificate /LE_CERTS/${zoneNameArg}/fullchain.pem;
|
ssl_certificate ${paths.nginxHostDirPath}/${hostNameArg}.public.pem;
|
||||||
ssl_certificate_key /LE_CERTS/${zoneNameArg}/privkey.pem;
|
ssl_certificate_key ${paths.nginxHostDirPath}/${hostNameArg}.private.pem;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://${zoneNameArg};
|
proxy_http_version 1.1;
|
||||||
include /etc/nginx/proxy_params;
|
proxy_buffering off;
|
||||||
}
|
proxy_redirect off;
|
||||||
location ~ /\.git {
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
deny all;
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_next_upstream error timeout http_404 http_429 http_500 http_502;
|
||||||
|
proxy_next_upstream_tries 5;
|
||||||
|
proxy_pass http://${hostNameArg};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
return zoneConfig;
|
return hostConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user