Compare commits
141 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
d8a4c3d088 | |||
e2639fd0a9 | |||
b5a27d5108 | |||
f32002309d | |||
52c3b40879 | |||
6de1352f5f | |||
c55977d5e4 | |||
ad986c1efe | |||
ca2ff3481e | |||
effe9210fc | |||
e49a358b22 | |||
a2bf0315ac | |||
2caa3c3d1a | |||
92307b187d | |||
e0757600b6 | |||
244b21ca36 | |||
87eb7084c0 | |||
e77b3d0355 | |||
871ff06040 | |||
1f2105f75e | |||
43e8549042 |
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
|
22
.gitignore
vendored
22
.gitignore
vendored
@ -1,4 +1,20 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
nginxconfig/zones/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
docs/
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
101
.gitlab-ci.yml
101
.gitlab-ci.yml
@ -1,36 +1,119 @@
|
|||||||
image: hosttoday/ht-docker-node:npmts
|
# gitzone ci_default
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
|
- metadata
|
||||||
|
|
||||||
testLEGACY:
|
# ====================
|
||||||
stage: test
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
allow_failure: true
|
- notpriv
|
||||||
|
|
||||||
|
snyk:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install -g snyk
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command snyk test
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci npm prepare
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
testSTABLE:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci npm prepare
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install lts
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
allow_failure: true
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g tslint typescript
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
pages:
|
||||||
|
image: hosttoday/ht-docker-dbase:npmci
|
||||||
|
services:
|
||||||
|
- docker:18-dind
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
artifacts:
|
||||||
|
expire_in: 1 week
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
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 Lossless 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.
|
20
README.md
20
README.md
@ -1,20 +0,0 @@
|
|||||||
# smartnginx
|
|
||||||
control nginx from node, TypeScript ready
|
|
||||||
|
|
||||||
## Status
|
|
||||||
[](https://gitlab.com/pushrocks/smartnginx/commits/master)
|
|
||||||
|
|
||||||
## 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 restarts nginx
|
|
||||||
```
|
|
4
dist/index.d.ts
vendored
4
dist/index.d.ts
vendored
@ -1,4 +0,0 @@
|
|||||||
import * as CommandModule from "./smartnginx.command";
|
|
||||||
export { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
|
||||||
export { NginxZone, zoneTypes } from "./smartnginx.classes.nginxzone";
|
|
||||||
export declare let command: typeof CommandModule;
|
|
11
dist/index.js
vendored
11
dist/index.js
vendored
@ -1,11 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var CommandModule = require("./smartnginx.command");
|
|
||||||
// classes
|
|
||||||
var smartnginx_classes_nginxconfig_1 = require("./smartnginx.classes.nginxconfig");
|
|
||||||
exports.NginxConfig = smartnginx_classes_nginxconfig_1.NginxConfig;
|
|
||||||
var smartnginx_classes_nginxzone_1 = require("./smartnginx.classes.nginxzone");
|
|
||||||
exports.NginxZone = smartnginx_classes_nginxzone_1.NginxZone;
|
|
||||||
exports.zoneTypes = smartnginx_classes_nginxzone_1.zoneTypes;
|
|
||||||
// exports
|
|
||||||
exports.command = CommandModule;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsSUFBWSxhQUFhLFdBQU0sc0JBQXNCLENBQUMsQ0FBQTtBQUV0RCxVQUFVO0FBQ1YsK0NBQTBCLGtDQUFrQyxDQUFDO0FBQXJELG1FQUFxRDtBQUM3RCw2Q0FBa0MsZ0NBQWdDLENBQUM7QUFBM0QsNkRBQVM7QUFBQyw2REFBaUQ7QUFFbkUsVUFBVTtBQUNDLGVBQU8sR0FBRyxhQUFhLENBQUMifQ==
|
|
10
dist/smartnginx.classes.nginxconfig.d.ts
vendored
10
dist/smartnginx.classes.nginxconfig.d.ts
vendored
@ -1,10 +0,0 @@
|
|||||||
import { NginxZone } from "./smartnginx.classes.nginxzone";
|
|
||||||
export declare class NginxConfig {
|
|
||||||
zones: NginxZone[];
|
|
||||||
isDeployed: boolean;
|
|
||||||
constructor();
|
|
||||||
addZone(zoneArg: NginxZone): void;
|
|
||||||
listZones(): NginxZone[];
|
|
||||||
removeZones(zoneArg: NginxZone): void;
|
|
||||||
deploy(nginxRestartArg?: boolean): void;
|
|
||||||
}
|
|
47
dist/smartnginx.classes.nginxconfig.js
vendored
47
dist/smartnginx.classes.nginxconfig.js
vendored
@ -1,47 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartnginx.plugins");
|
|
||||||
var paths = require("./smartnginx.paths");
|
|
||||||
var command = require("./smartnginx.command");
|
|
||||||
var snippets = require("./smartnginx.snippets");
|
|
||||||
var allConfigs = [];
|
|
||||||
var NginxConfig = (function () {
|
|
||||||
function NginxConfig() {
|
|
||||||
this.isDeployed = false;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
// interact with Zones
|
|
||||||
NginxConfig.prototype.addZone = function (zoneArg) {
|
|
||||||
};
|
|
||||||
NginxConfig.prototype.listZones = function () {
|
|
||||||
return this.zones;
|
|
||||||
};
|
|
||||||
;
|
|
||||||
NginxConfig.prototype.removeZones = function (zoneArg) {
|
|
||||||
};
|
|
||||||
// handle deployment of zones
|
|
||||||
NginxConfig.prototype.deploy = function (nginxRestartArg) {
|
|
||||||
if (nginxRestartArg === void 0) { nginxRestartArg = false; }
|
|
||||||
plugins.smartfile.fs.remove(paths.nginxConfigBase);
|
|
||||||
plugins.smartfile.fs.ensureDir(paths.nginxConfigBase);
|
|
||||||
for (var _i = 0, allConfigs_1 = allConfigs; _i < allConfigs_1.length; _i++) {
|
|
||||||
var config = allConfigs_1[_i];
|
|
||||||
config.isDeployed = false;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
this.isDeployed = true;
|
|
||||||
for (var _a = 0, _b = this.zones; _a < _b.length; _a++) {
|
|
||||||
var zone = _b[_a];
|
|
||||||
zone.deploy();
|
|
||||||
}
|
|
||||||
;
|
|
||||||
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(), plugins.path.join(paths.nginxConfigBase, "nginx.conf"));
|
|
||||||
if (nginxRestartArg) {
|
|
||||||
command.restart(this);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
;
|
|
||||||
return NginxConfig;
|
|
||||||
}());
|
|
||||||
exports.NginxConfig = NginxConfig;
|
|
||||||
;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxzQkFBc0IsQ0FBQyxDQUFBO0FBQ2hELElBQVksS0FBSyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFDNUMsSUFBWSxPQUFPLFdBQU0sc0JBQXNCLENBQUMsQ0FBQTtBQUNoRCxJQUFZLFFBQVEsV0FBTSx1QkFDMUIsQ0FBQyxDQURnRDtBQUVqRCxJQUFJLFVBQVUsR0FBaUIsRUFBRSxDQUFDO0FBRWxDO0lBR0k7UUFEQSxlQUFVLEdBQVcsS0FBSyxDQUFDO0lBRzNCLENBQUM7O0lBRUQsc0JBQXNCO0lBQ3RCLDZCQUFPLEdBQVAsVUFBUSxPQUFpQjtJQUV6QixDQUFDO0lBQ0QsK0JBQVMsR0FBVDtRQUNJLE1BQU0sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDO0lBQ3RCLENBQUM7O0lBQ0QsaUNBQVcsR0FBWCxVQUFZLE9BQWlCO0lBRTdCLENBQUM7SUFFRCw2QkFBNkI7SUFDN0IsNEJBQU0sR0FBTixVQUFPLGVBQStCO1FBQS9CLCtCQUErQixHQUEvQix1QkFBK0I7UUFDbEMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsTUFBTSxDQUFDLEtBQUssQ0FBQyxlQUFlLENBQUMsQ0FBQztRQUNuRCxPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLGVBQWUsQ0FBQyxDQUFDO1FBQ3RELEdBQUcsQ0FBQSxDQUFlLFVBQVUsRUFBVix5QkFBVSxFQUFWLHdCQUFVLEVBQVYsSUFBVSxDQUFDO1lBQXpCLElBQUksTUFBTSxtQkFBQTtZQUNWLE1BQU0sQ0FBQyxVQUFVLEdBQUcsS0FBSyxDQUFDO1NBQzdCO1FBQUEsQ0FBQztRQUNGLElBQUksQ0FBQyxVQUFVLEdBQUcsSUFBSSxDQUFDO1FBQ3ZCLEdBQUcsQ0FBQSxDQUFhLFVBQVUsRUFBVixLQUFBLElBQUksQ0FBQyxLQUFLLEVBQVYsY0FBVSxFQUFWLElBQVUsQ0FBQztZQUF2QixJQUFJLElBQUksU0FBQTtZQUNSLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQztTQUNqQjtRQUFBLENBQUM7UUFDRixPQUFPLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQzdCLFFBQVEsQ0FBQyxtQkFBbUIsRUFBRSxFQUM5QixPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsZUFBZSxFQUFDLFlBQVksQ0FBQyxDQUN4RCxDQUFDO1FBQ0YsRUFBRSxDQUFBLENBQUMsZUFBZSxDQUFDLENBQUEsQ0FBQztZQUNoQixPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQzFCLENBQUM7SUFDTCxDQUFDOztJQUVMLGtCQUFDO0FBQUQsQ0FBQyxBQXRDRCxJQXNDQztBQXRDWSxtQkFBVyxjQXNDdkIsQ0FBQTtBQUFBLENBQUMifQ==
|
|
14
dist/smartnginx.classes.nginxzone.d.ts
vendored
14
dist/smartnginx.classes.nginxzone.d.ts
vendored
@ -1,14 +0,0 @@
|
|||||||
export declare enum zoneTypes {
|
|
||||||
reverseProxy = 0,
|
|
||||||
static = 1,
|
|
||||||
}
|
|
||||||
export declare class NginxZone {
|
|
||||||
zoneName: string;
|
|
||||||
configString: string;
|
|
||||||
constructor(optionsArg: {
|
|
||||||
zoneName: string;
|
|
||||||
type: zoneTypes;
|
|
||||||
destination: string;
|
|
||||||
});
|
|
||||||
deploy(): void;
|
|
||||||
}
|
|
24
dist/smartnginx.classes.nginxzone.js
vendored
24
dist/smartnginx.classes.nginxzone.js
vendored
@ -1,24 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartnginx.plugins");
|
|
||||||
var paths = require("./smartnginx.paths");
|
|
||||||
var snippets = require("./smartnginx.snippets");
|
|
||||||
(function (zoneTypes) {
|
|
||||||
zoneTypes[zoneTypes["reverseProxy"] = 0] = "reverseProxy";
|
|
||||||
zoneTypes[zoneTypes["static"] = 1] = "static";
|
|
||||||
})(exports.zoneTypes || (exports.zoneTypes = {}));
|
|
||||||
var zoneTypes = exports.zoneTypes;
|
|
||||||
var NginxZone = (function () {
|
|
||||||
function NginxZone(optionsArg) {
|
|
||||||
this.configString = snippets.getZoneConfigString(optionsArg.zoneName, optionsArg.destination);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
NginxZone.prototype.deploy = function () {
|
|
||||||
var filePath = plugins.path.join(paths.nginxZoneBase, this.zoneName + ".conf");
|
|
||||||
plugins.smartfile.memory.toFsSync(this.configString, filePath);
|
|
||||||
};
|
|
||||||
;
|
|
||||||
return NginxZone;
|
|
||||||
}());
|
|
||||||
exports.NginxZone = NginxZone;
|
|
||||||
;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54em9uZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguY2xhc3Nlcy5uZ2lueHpvbmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsSUFBWSxLQUFLLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUU1QyxJQUFZLFFBQVEsV0FBTSx1QkFDMUIsQ0FBQyxDQURnRDtBQUNqRCxXQUFZLFNBQVM7SUFDZCx5REFBWSxDQUFBO0lBQ1osNkNBQU0sQ0FBQTtBQUNiLENBQUMsRUFIVyxpQkFBUyxLQUFULGlCQUFTLFFBR3BCO0FBSEQsSUFBWSxTQUFTLEdBQVQsaUJBR1gsQ0FBQTtBQUVEO0lBR0ksbUJBQVksVUFJWDtRQUNHLElBQUksQ0FBQyxZQUFZLEdBQUcsUUFBUSxDQUFDLG1CQUFtQixDQUFDLFVBQVUsQ0FBQyxRQUFRLEVBQUMsVUFBVSxDQUFDLFdBQVcsQ0FBQyxDQUFDO0lBQ2pHLENBQUM7O0lBQ0QsMEJBQU0sR0FBTjtRQUNJLElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxhQUFhLEVBQUMsSUFBSSxDQUFDLFFBQVEsR0FBRyxPQUFPLENBQUMsQ0FBQztRQUM5RSxPQUFPLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFlBQVksRUFBQyxRQUFRLENBQUMsQ0FBQztJQUNsRSxDQUFDOztJQUNMLGdCQUFDO0FBQUQsQ0FBQyxBQWRELElBY0M7QUFkWSxpQkFBUyxZQWNyQixDQUFBO0FBQUEsQ0FBQyJ9
|
|
14
dist/smartnginx.command.d.ts
vendored
14
dist/smartnginx.command.d.ts
vendored
@ -1,14 +0,0 @@
|
|||||||
import { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
|
||||||
/**
|
|
||||||
* starts nginx
|
|
||||||
*/
|
|
||||||
export declare let start: (configArg: NginxConfig) => void;
|
|
||||||
export declare let restart: (configArg: NginxConfig) => void;
|
|
||||||
/**
|
|
||||||
* stops nginx
|
|
||||||
*/
|
|
||||||
export declare let stop: () => void;
|
|
||||||
/**
|
|
||||||
* checks if nginx is in path
|
|
||||||
*/
|
|
||||||
export declare let check: () => boolean;
|
|
22
dist/smartnginx.command.js
vendored
22
dist/smartnginx.command.js
vendored
@ -1,22 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
/**
|
|
||||||
* starts nginx
|
|
||||||
*/
|
|
||||||
exports.start = function (configArg) {
|
|
||||||
};
|
|
||||||
exports.restart = function (configArg) {
|
|
||||||
exports.stop();
|
|
||||||
exports.start(configArg);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* stops nginx
|
|
||||||
*/
|
|
||||||
exports.stop = function () {
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* checks if nginx is in path
|
|
||||||
*/
|
|
||||||
exports.check = function () {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jb21tYW5kLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jb21tYW5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFJQTs7R0FFRztBQUNRLGFBQUssR0FBRyxVQUFDLFNBQXFCO0FBRXpDLENBQUMsQ0FBQztBQUVTLGVBQU8sR0FBRyxVQUFDLFNBQXFCO0lBQ3ZDLFlBQUksRUFBRSxDQUFDO0lBQ1AsYUFBSyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQ3JCLENBQUMsQ0FBQTtBQUVEOztHQUVHO0FBQ1EsWUFBSSxHQUFHO0FBRWxCLENBQUMsQ0FBQztBQUVGOztHQUVHO0FBQ1EsYUFBSyxHQUFHO0lBQ2YsTUFBTSxDQUFDO0FBQ1gsQ0FBQyxDQUFDIn0=
|
|
3
dist/smartnginx.paths.d.ts
vendored
3
dist/smartnginx.paths.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
export declare let packageBase: string;
|
|
||||||
export declare let nginxConfigBase: string;
|
|
||||||
export declare let nginxZoneBase: string;
|
|
6
dist/smartnginx.paths.js
vendored
6
dist/smartnginx.paths.js
vendored
@ -1,6 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartnginx.plugins");
|
|
||||||
exports.packageBase = plugins.path.join(__dirname, "../");
|
|
||||||
exports.nginxConfigBase = plugins.path.join(exports.packageBase, "nginxconfig/");
|
|
||||||
exports.nginxZoneBase = plugins.path.join(exports.nginxConfigBase, "zones");
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wYXRocy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbngucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLHNCQUV6QixDQUFDLENBRjhDO0FBRXBDLG1CQUFXLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLEtBQUssQ0FBQyxDQUFDO0FBQ2pELHVCQUFlLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsbUJBQVcsRUFBQyxjQUFjLENBQUMsQ0FBQztBQUNoRSxxQkFBYSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLHVCQUFlLEVBQUMsT0FBTyxDQUFDLENBQUMifQ==
|
|
7
dist/smartnginx.plugins.d.ts
vendored
7
dist/smartnginx.plugins.d.ts
vendored
@ -1,7 +0,0 @@
|
|||||||
import "typings-global";
|
|
||||||
export import cert = require("cert");
|
|
||||||
export import path = require("path");
|
|
||||||
export import q = require("q");
|
|
||||||
export declare let shelljs: any;
|
|
||||||
export import smartfile = require("smartfile");
|
|
||||||
export import smartstring = require("smartstring");
|
|
9
dist/smartnginx.plugins.js
vendored
9
dist/smartnginx.plugins.js
vendored
@ -1,9 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
exports.cert = require("cert");
|
|
||||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixZQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDdkIsWUFBSSxXQUFXLE1BQU0sQ0FBQyxDQUFDO0FBQ3ZCLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUNwQixlQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQzFCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyJ9
|
|
2
dist/smartnginx.snippets.d.ts
vendored
2
dist/smartnginx.snippets.d.ts
vendored
@ -1,2 +0,0 @@
|
|||||||
export declare let getBaseConfigString: () => void;
|
|
||||||
export declare let getZoneConfigString: (zoneNameArg: string, destinationIpArg: string) => string;
|
|
10
dist/smartnginx.snippets.js
vendored
10
dist/smartnginx.snippets.js
vendored
@ -1,10 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var plugins = require("./smartnginx.plugins");
|
|
||||||
exports.getBaseConfigString = function () {
|
|
||||||
var baseConfig = plugins.smartstring.indent.normalize("\n\t\tuser www-data;\n\t\tworker_processes auto;\n\t\tpid /run/nginx.pid;\n\n\t\tevents {\n\t\t\tworker_connections 768;\n\t\t\t# multi_accept on;\n\t\t}\n\n\t\thttp {\n\t\t\tserver_names_hash_bucket_size 128;\n\n\t\t\t##\n\t\t\t# Basic Settings\n\t\t\t##\n\n\t\t\tsendfile on;\n\t\t\ttcp_nopush on;\n\t\t\ttcp_nodelay on;\n\t\t\tkeepalive_timeout 65;\n\t\t\ttypes_hash_max_size 2048;\n\t\t\t# server_tokens off;\n\n\t\t\t# server_names_hash_bucket_size 64;\n\t\t\t# server_name_in_redirect off;\n\n\t\t\tinclude /etc/nginx/mime.types;\n\t\t\tdefault_type application/octet-stream;\n\n\t\t\t##\n\t\t\t# SSL Settings\n\t\t\t##\n\n\t\t\tssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE\n\t\t\tssl_prefer_server_ciphers on;\n\n\t\t\t##\n\t\t\t# Logging Settings\n\t\t\t##\n\n\t\t\taccess_log /var/log/nginx/access.log;\n\t\t\terror_log /var/log/nginx/error.log;\n\n\t\t\t##\n\t\t\t# Gzip Settings\n\t\t\t##\n\n\t\t\tgzip on;\n\t\t\tgzip_disable \"msie6\";\n\n\t\t\t# gzip_vary on;\n\t\t\t# gzip_proxied any;\n\t\t\t# gzip_comp_level 6;\n\t\t\t# gzip_buffers 16 8k;\n\t\t\t# gzip_http_version 1.1;\n\t\t\t# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;\n\n\t\t\t##\n\t\t\t# Virtual Host Configs\n\t\t\t##\n\n\t\t\tinclude /etc/nginx/conf.d/*.conf;\n\t\t\tinclude /etc/nginx/sites-enabled/*;\n\t\t}\n\t\tdaemon off;\n\t");
|
|
||||||
};
|
|
||||||
exports.getZoneConfigString = function (zoneNameArg, destinationIpArg) {
|
|
||||||
var zoneConfig = plugins.smartstring.indent.normalize("\n\t\tupstream " + zoneNameArg + " {\n\t\t\tserver " + destinationIpArg + ";\n\t\t}\n\n\t\tserver {\n\t\t\tlisten *:80 ;\n\t\t\tserver_name " + zoneNameArg + ";\n\t\t\trewrite ^ https://" + zoneNameArg + "$request_uri? permanent;\n\t\t}\n\n\t\tserver {\n\t\t\tlisten *:443 ssl;\n\t\t\tserver_name " + zoneNameArg + ";\n\t\t\tssl_certificate /LE_CERTS/" + zoneNameArg + "/fullchain.pem;\n\t\t\tssl_certificate_key /LE_CERTS/" + zoneNameArg + "/privkey.pem;\n\n\t\t\tlocation / {\n\t\t\t\tproxy_pass http://" + zoneNameArg + ";\n\t\t\t\tinclude /etc/nginx/proxy_params;\n\t\t\t}\n\t\t\tlocation ~ /.git {\n\t\t\t\tdeny all;\n\t\t\t}\n\t\t}\n\t");
|
|
||||||
return zoneConfig;
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5zbmlwcGV0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguc25pcHBldHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDckMsMkJBQW1CLEdBQUc7SUFDaEMsSUFBSSxVQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLDY0Q0FrRXJELENBQUMsQ0FBQztBQUNKLENBQUMsQ0FBQTtBQUdVLDJCQUFtQixHQUFHLFVBQUMsV0FBa0IsRUFBQyxnQkFBdUI7SUFDM0UsSUFBSSxVQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLG9CQUMxQyxXQUFXLHlCQUNaLGdCQUFnQix5RUFLWCxXQUFXLDBDQUNFLFdBQVcsb0dBS3hCLFdBQVcsMkNBQ0csV0FBVyw2REFDUCxXQUFXLHVFQUd0QixXQUFXLDBIQU9qQyxDQUFDLENBQUM7SUFDSCxNQUFNLENBQUMsVUFBVSxDQUFDO0FBQ25CLENBQUMsQ0FBQyJ9
|
|
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-----
|
15
nginxconfig/hosts/default.private.pem
Normal file
15
nginxconfig/hosts/default.private.pem
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIICXQIBAAKBgQD5b6wtr4xHY5gxH0SR+V9XIQPH6DGe2PXlKWN02dgvg7Ej/4uA
|
||||||
|
7MmOnem2SUpWE2GwuKCAUCeZkj+riEmky0EWFexaM3BmcvWLSHZ6MAYg5FxTsUG8
|
||||||
|
IXxNYUdTPpUBxaCX/yp/dvpiDqSMH67y9LwI85oWHx/zk1jMixaZXvOCXwIDAQAB
|
||||||
|
AoGBALFXn1/f9uluuu753yO12/4zf9+qi1T3xmQGuCqFE7o8dD422vVv5KHcTiUH
|
||||||
|
GK34G7Wsnph75JvAKjqHrGxZAk0NN59VK4Sl141S7qzXgjQf5Ks7r5y8v8AQgvEM
|
||||||
|
zOwutOqlGNHJZ1NlCDJuMNxUe/vyRXRl1WDCeJF6pt8huZgRAkEA/Ppqz8NyU+B7
|
||||||
|
kaz3e39uCELsyaDl3Xf82JMmJASBlndso3l3H2ihihAMYHaH21IxKQnfaiKMyfK4
|
||||||
|
tvONLB/eZwJBAPxqbKEzLqYM7ds8QG2fty7heIcwtcKjTMThl99/OinNsJdd0DUE
|
||||||
|
GPBVaDlvqijEk5R4oQ5CkzrQDe6mVkt90UkCQEogChoUl7RSC4MU3nM2VIRhL8ao
|
||||||
|
uZHaLaE8BKn7FAmFtrRzy97NJsAwkZ/WO1qdS8BNn0QXGY+26j7ZQF1UfTMCQG8W
|
||||||
|
u4Zaiz5DVG93XfehIjK8wpnlAymNSx0fGAMh8EwznXOQszCSBBPJ0tvsXBwjH7xp
|
||||||
|
NqCbBkcNCASvKi2BSxkCQQDphVUlroFh6n4KEfrVQkzHoGU2pWfwTekCwneJ1w8r
|
||||||
|
omwcagWn7E0a2DDj7tONmY7NU3kwRU2fLIzdG4Y9rewO
|
||||||
|
-----END RSA PRIVATE KEY-----
|
13
nginxconfig/hosts/default.public.pem
Normal file
13
nginxconfig/hosts/default.public.pem
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIB/zCCAWigAwIBAgIJH3Pl1mivagGCMA0GCSqGSIb3DQEBBQUAMB4xHDAaBgNV
|
||||||
|
BAMTE3NlbGZzaWduZWQuZ2l0LnpvbmUwHhcNMjMwNzI2MTQwNTIwWhcNMjQwNzI1
|
||||||
|
MTQwNTIwWjAeMRwwGgYDVQQDExNzZWxmc2lnbmVkLmdpdC56b25lMIGfMA0GCSqG
|
||||||
|
SIb3DQEBAQUAA4GNADCBiQKBgQD5b6wtr4xHY5gxH0SR+V9XIQPH6DGe2PXlKWN0
|
||||||
|
2dgvg7Ej/4uA7MmOnem2SUpWE2GwuKCAUCeZkj+riEmky0EWFexaM3BmcvWLSHZ6
|
||||||
|
MAYg5FxTsUG8IXxNYUdTPpUBxaCX/yp/dvpiDqSMH67y9LwI85oWHx/zk1jMixaZ
|
||||||
|
XvOCXwIDAQABo0UwQzAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIC9DAmBgNVHREE
|
||||||
|
HzAdhhtodHRwOi8vZXhhbXBsZS5vcmcvd2ViaWQjbWUwDQYJKoZIhvcNAQEFBQAD
|
||||||
|
gYEAQ0pJ279EDgvsY+YjslMdUaJbZcF9rFgUE3t8vDDZH99kth8gqNddahcLqEV2
|
||||||
|
8hyx7qcnplpKNVx8DYvDWoTGRdXBhCP/TBBW3jdsqaBHJey+yfAISBk4pbOow260
|
||||||
|
tNQngsMDf+PZQMLm2bT1Pxk2KXd0rFMkVWprcRs2qx3Yz0Q=
|
||||||
|
-----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/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/test100.bleu.de.public.pem;
|
||||||
|
ssl_certificate_key /mnt/HC_Volume_11396573/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/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/test102.bleu.de.public.pem;
|
||||||
|
ssl_certificate_key /mnt/HC_Volume_11396573/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
|
@ -1,6 +1,6 @@
|
|||||||
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;
|
||||||
@ -59,7 +59,21 @@ http {
|
|||||||
# Virtual Host Configs
|
# Virtual Host Configs
|
||||||
##
|
##
|
||||||
|
|
||||||
include /etc/nginx/conf.d/*.conf;
|
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/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/default.public.pem;
|
||||||
|
ssl_certificate_key /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/default.private.pem;
|
||||||
|
rewrite ^ https://git.zone redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
include /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/*.conf;
|
||||||
include /etc/nginx/sites-enabled/*;
|
include /etc/nginx/sites-enabled/*;
|
||||||
}
|
}
|
||||||
daemon off;
|
daemon off;
|
17
npmextra.json
Normal file
17
npmextra.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"npmdocker": {},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "smartnginx",
|
||||||
|
"description": "control nginx from node, TypeScript ready",
|
||||||
|
"npmPackagename": "@push.rocks/smartnginx",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
54
package.json
54
package.json
@ -1,11 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "smartnginx",
|
"name": "@push.rocks/smartnginx",
|
||||||
"version": "0.0.3",
|
"version": "2.0.52",
|
||||||
|
"private": false,
|
||||||
"description": "control nginx from node, TypeScript ready",
|
"description": "control nginx from node, TypeScript ready",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "tstest test/",
|
||||||
|
"cleanTest": "(rm -r nginxconfig) && npm run test",
|
||||||
|
"build": "(tsbuild --allowimplicitany)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -21,16 +24,37 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartnginx#README",
|
"homepage": "https://gitlab.com/pushrocks/smartnginx#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/q": "0.0.25-alpha",
|
"@push.rocks/lik": "^6.0.2",
|
||||||
"cert": "0.0.13",
|
"@push.rocks/smartfile": "^10.0.26",
|
||||||
"q": "^1.4.1",
|
"@push.rocks/smartlog": "^3.0.2",
|
||||||
"shelljs": "^0.7.0",
|
"@push.rocks/smartpath": "^5.0.11",
|
||||||
"smartfile": "^4.0.10",
|
"@push.rocks/smartpromise": "^4.0.2",
|
||||||
"smartstring": "^2.0.14"
|
"@push.rocks/smartshell": "^3.0.3",
|
||||||
|
"@push.rocks/smartstring": "^4.0.7",
|
||||||
|
"@push.rocks/smartunique": "^3.0.3",
|
||||||
|
"selfsigned": "^2.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts-g": "^5.2.6",
|
"@gitzone/tsbuild": "^2.1.66",
|
||||||
"should": "^9.0.2",
|
"@gitzone/tsrun": "^1.2.44",
|
||||||
"typings-test": "^1.0.1"
|
"@gitzone/tstest": "^1.0.77",
|
||||||
}
|
"@push.rocks/qenv": "^5.0.2",
|
||||||
|
"@push.rocks/tapbundle": "^5.0.8"
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
4819
pnpm-lock.yaml
generated
Normal file
4819
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
2
test/test.d.ts
vendored
2
test/test.d.ts
vendored
@ -1,2 +0,0 @@
|
|||||||
import "typings-test";
|
|
||||||
import "should";
|
|
27
test/test.js
27
test/test.js
@ -1,27 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-test");
|
|
||||||
require("should");
|
|
||||||
var smartnginx = require("../dist/index");
|
|
||||||
describe("smartnginx", function () {
|
|
||||||
var testNginxConfig;
|
|
||||||
var testNginxZone01;
|
|
||||||
var testNginxZone02;
|
|
||||||
describe("NginxZone", function () {
|
|
||||||
it("\"new NginxZone()\" should produce an instance of NginxConfig", function () {
|
|
||||||
testNginxZone01 = new smartnginx.NginxZone({
|
|
||||||
zoneName: "test1.bleu.de",
|
|
||||||
type: smartnginx.zoneTypes.reverseProxy,
|
|
||||||
destination: "192.192.192.192"
|
|
||||||
});
|
|
||||||
testNginxZone01.should.be.instanceof(smartnginx.NginxZone);
|
|
||||||
console.log(testNginxZone01.configString);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe("NginxConfig", function () {
|
|
||||||
it("\"new NginxConfig()\" should produce an instance of NginxConfig", function () {
|
|
||||||
testNginxConfig = new smartnginx.NginxConfig();
|
|
||||||
testNginxConfig.should.be.instanceof(smartnginx.NginxConfig);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQixJQUFZLFVBQVUsV0FBTSxlQUFlLENBQUMsQ0FBQTtBQUU1QyxRQUFRLENBQUMsWUFBWSxFQUFDO0lBQ2xCLElBQUksZUFBc0MsQ0FBQztJQUMzQyxJQUFJLGVBQW9DLENBQUM7SUFDekMsSUFBSSxlQUFvQyxDQUFDO0lBQ3pDLFFBQVEsQ0FBQyxXQUFXLEVBQUM7UUFDakIsRUFBRSxDQUFDLCtEQUE2RCxFQUFDO1lBQzdELGVBQWUsR0FBRyxJQUFJLFVBQVUsQ0FBQyxTQUFTLENBQUM7Z0JBQ3ZDLFFBQVEsRUFBQyxlQUFlO2dCQUN4QixJQUFJLEVBQUMsVUFBVSxDQUFDLFNBQVMsQ0FBQyxZQUFZO2dCQUN0QyxXQUFXLEVBQUMsaUJBQWlCO2FBQ2hDLENBQUMsQ0FBQztZQUNILGVBQWUsQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLENBQUM7WUFDM0QsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUMsWUFBWSxDQUFDLENBQUM7UUFDOUMsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDLENBQUMsQ0FBQztJQUNILFFBQVEsQ0FBQyxhQUFhLEVBQUM7UUFDbkIsRUFBRSxDQUFDLGlFQUErRCxFQUFDO1lBQy9ELGVBQWUsR0FBRyxJQUFJLFVBQVUsQ0FBQyxXQUFXLEVBQUUsQ0FBQztZQUMvQyxlQUFlLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsVUFBVSxDQUFDLFdBQVcsQ0FBQyxDQUFDO1FBQ2pFLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyJ9
|
|
77
test/test.ts
77
test/test.ts
@ -1,26 +1,55 @@
|
|||||||
import "typings-test";
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
import "should";
|
import path = require('path');
|
||||||
import * as smartnginx from "../dist/index";
|
|
||||||
|
|
||||||
describe("smartnginx",function(){
|
import { Qenv } from '@push.rocks/qenv';
|
||||||
let testNginxConfig:smartnginx.NginxConfig;
|
const testQenv = new Qenv('./', './.nogit/');
|
||||||
let testNginxZone01:smartnginx.NginxZone;
|
|
||||||
let testNginxZone02:smartnginx.NginxZone;
|
import * as smartnginx from '../ts/index.js';
|
||||||
describe("NginxZone",function(){
|
|
||||||
it(`"new NginxZone()" should produce an instance of NginxConfig`,function(){
|
let testSmartNginx: smartnginx.SmartNginx;
|
||||||
testNginxZone01 = new smartnginx.NginxZone({
|
let testNginxZone01: smartnginx.NginxHost;
|
||||||
zoneName:"test1.bleu.de",
|
let testNginxZone02: smartnginx.NginxHost;
|
||||||
type:smartnginx.zoneTypes.reverseProxy,
|
|
||||||
destination:"192.192.192.192"
|
tap.test('should create a valid instance of SmartNginx', async () => {
|
||||||
});
|
testSmartNginx = new smartnginx.SmartNginx({ defaultProxyUrl: 'https://git.zone' });
|
||||||
testNginxZone01.should.be.instanceof(smartnginx.NginxZone);
|
expect(testSmartNginx).toBeInstanceOf(smartnginx.SmartNginx);
|
||||||
console.log(testNginxZone01.configString);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe("NginxConfig",function(){
|
|
||||||
it(`"new NginxConfig()" should produce an instance of NginxConfig`,function(){
|
|
||||||
testNginxConfig = new smartnginx.NginxConfig();
|
|
||||||
testNginxConfig.should.be.instanceof(smartnginx.NginxConfig);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
|
||||||
|
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 @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartnginx',
|
||||||
|
version: '2.0.52',
|
||||||
|
description: 'control nginx from node, TypeScript ready'
|
||||||
|
}
|
11
ts/index.ts
11
ts/index.ts
@ -1,9 +1,4 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
|
||||||
import * as CommandModule from "./smartnginx.command";
|
|
||||||
|
|
||||||
// classes
|
// classes
|
||||||
export {NginxConfig} from "./smartnginx.classes.nginxconfig";
|
export * from './smartnginx.classes.smartnginx.js';
|
||||||
export {NginxZone,zoneTypes} from "./smartnginx.classes.nginxzone";
|
export * from './smartnginx.classes.nginxprocess.js';
|
||||||
|
export * from './smartnginx.classes.nginxhost.js';
|
||||||
// exports
|
|
||||||
export let command = CommandModule;
|
|
||||||
|
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,46 +0,0 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
|
||||||
import * as paths from "./smartnginx.paths";
|
|
||||||
import * as command from "./smartnginx.command";
|
|
||||||
import * as snippets from "./smartnginx.snippets"
|
|
||||||
import {NginxZone} from "./smartnginx.classes.nginxzone";
|
|
||||||
let allConfigs:NginxConfig[] = [];
|
|
||||||
|
|
||||||
export class NginxConfig {
|
|
||||||
zones:NginxZone[];
|
|
||||||
isDeployed:boolean = false;
|
|
||||||
constructor(){
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// interact with Zones
|
|
||||||
addZone(zoneArg:NginxZone){
|
|
||||||
|
|
||||||
}
|
|
||||||
listZones():NginxZone[] {
|
|
||||||
return this.zones;
|
|
||||||
};
|
|
||||||
removeZones(zoneArg:NginxZone){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle deployment of zones
|
|
||||||
deploy(nginxRestartArg:boolean = false){
|
|
||||||
plugins.smartfile.fs.remove(paths.nginxConfigBase);
|
|
||||||
plugins.smartfile.fs.ensureDir(paths.nginxConfigBase);
|
|
||||||
for(let config of allConfigs){
|
|
||||||
config.isDeployed = false;
|
|
||||||
};
|
|
||||||
this.isDeployed = true;
|
|
||||||
for(let zone of this.zones){
|
|
||||||
zone.deploy();
|
|
||||||
};
|
|
||||||
plugins.smartfile.memory.toFsSync(
|
|
||||||
snippets.getBaseConfigString(),
|
|
||||||
plugins.path.join(paths.nginxConfigBase,"nginx.conf")
|
|
||||||
);
|
|
||||||
if(nginxRestartArg){
|
|
||||||
command.restart(this);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
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
|
||||||
|
);
|
||||||
|
plugins.smartfile.memory.toFsSync(this.configString, filePathConfig);
|
||||||
|
|
||||||
|
// write ssl
|
||||||
|
plugins.smartfile.memory.toFsSync(this.privateKey, filePathPrivate);
|
||||||
|
plugins.smartfile.memory.toFsSync(this.publicKey, filePathPublic);
|
||||||
|
}
|
||||||
|
}
|
67
ts/smartnginx.classes.nginxprocess.ts
Normal file
67
ts/smartnginx.classes.nginxprocess.ts
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import * as plugins from './smartnginx.plugins.js';
|
||||||
|
import * as paths from './smartnginx.paths.js';
|
||||||
|
import { SmartNginx } from './smartnginx.classes.smartnginx.js';
|
||||||
|
import { NginxHost } from './smartnginx.classes.nginxhost.js';
|
||||||
|
|
||||||
|
import { ChildProcess } from 'child_process';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* manages a nginxprocess for an NginxConfig
|
||||||
|
*/
|
||||||
|
export class NginxProcess {
|
||||||
|
public started: boolean = false;
|
||||||
|
public smartNginxRef: SmartNginx;
|
||||||
|
private nginxChildProcess: ChildProcess;
|
||||||
|
private smartshellInstance = new plugins.smartshell.Smartshell({
|
||||||
|
executor: 'bash',
|
||||||
|
});
|
||||||
|
|
||||||
|
constructor(nginxRefArg: SmartNginx) {
|
||||||
|
this.smartNginxRef = nginxRefArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* start nginx
|
||||||
|
*/
|
||||||
|
public async start() {
|
||||||
|
if (!this.nginxChildProcess) {
|
||||||
|
this.nginxChildProcess = (
|
||||||
|
await this.smartshellInstance.execStreaming(`nginx -c ${paths.nginxConfFile}`)
|
||||||
|
).childProcess;
|
||||||
|
}
|
||||||
|
this.started = true;
|
||||||
|
console.log('info', 'started Nginx!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reload config
|
||||||
|
*/
|
||||||
|
public async reloadConfig() {
|
||||||
|
if (!this.started) {
|
||||||
|
this.start();
|
||||||
|
} else {
|
||||||
|
await this.smartshellInstance.exec('nginx -s reload');
|
||||||
|
}
|
||||||
|
this.smartNginxRef.logger.log('info', 'NginxProcess has loaded the new config!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stop the nginx instance
|
||||||
|
*/
|
||||||
|
public async stop() {
|
||||||
|
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,24 +0,0 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
|
||||||
import * as paths from "./smartnginx.paths";
|
|
||||||
import * as command from "./smartnginx.command";
|
|
||||||
import * as snippets from "./smartnginx.snippets"
|
|
||||||
export enum zoneTypes {
|
|
||||||
reverseProxy,
|
|
||||||
static
|
|
||||||
}
|
|
||||||
|
|
||||||
export class NginxZone {
|
|
||||||
zoneName:string; // the zone name e.g. domain name
|
|
||||||
configString:string; // the actual zone config file as string
|
|
||||||
constructor(optionsArg:{
|
|
||||||
zoneName:string,
|
|
||||||
type:zoneTypes,
|
|
||||||
destination:string
|
|
||||||
}){
|
|
||||||
this.configString = snippets.getZoneConfigString(optionsArg.zoneName,optionsArg.destination);
|
|
||||||
};
|
|
||||||
deploy(){
|
|
||||||
let filePath = plugins.path.join(paths.nginxZoneBase,this.zoneName + ".conf");
|
|
||||||
plugins.smartfile.memory.toFsSync(this.configString,filePath);
|
|
||||||
};
|
|
||||||
};
|
|
160
ts/smartnginx.classes.smartnginx.ts
Normal file
160
ts/smartnginx.classes.smartnginx.ts
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
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
|
||||||
|
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigDirPath);
|
||||||
|
plugins.smartfile.memory.toFsSync(
|
||||||
|
snippets.getBaseConfigString(this.options.defaultProxyUrl),
|
||||||
|
paths.nginxConfFile
|
||||||
|
);
|
||||||
|
|
||||||
|
// write standard self signed certificate
|
||||||
|
const selfsignedCert = plugins.selfsigned.generate(
|
||||||
|
[{ name: 'commonName', value: 'selfsigned.git.zone' }],
|
||||||
|
{ days: 365 }
|
||||||
|
);
|
||||||
|
|
||||||
|
// deploy hosts
|
||||||
|
plugins.smartfile.fs.ensureDirSync(paths.nginxHostDirPath);
|
||||||
|
plugins.smartfile.memory.toFsSync(
|
||||||
|
selfsignedCert.private,
|
||||||
|
plugins.path.join(paths.nginxHostDirPath, './default.private.pem')
|
||||||
|
);
|
||||||
|
plugins.smartfile.memory.toFsSync(
|
||||||
|
selfsignedCert.cert,
|
||||||
|
plugins.path.join(paths.nginxHostDirPath, './default.public.pem')
|
||||||
|
);
|
||||||
|
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,29 +0,0 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
|
||||||
import {NginxConfig} from "./smartnginx.classes.nginxconfig";
|
|
||||||
import {NginxZone} from "./smartnginx.classes.nginxzone";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* starts nginx
|
|
||||||
*/
|
|
||||||
export let start = (configArg:NginxConfig) => {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
export let restart = (configArg:NginxConfig) => {
|
|
||||||
stop();
|
|
||||||
start(configArg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* stops nginx
|
|
||||||
*/
|
|
||||||
export let stop = () => {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* checks if nginx is in path
|
|
||||||
*/
|
|
||||||
export let check = ():boolean => {
|
|
||||||
return;
|
|
||||||
};
|
|
@ -1,5 +1,9 @@
|
|||||||
import * as plugins from "./smartnginx.plugins"
|
import * as plugins from './smartnginx.plugins.js';
|
||||||
|
|
||||||
export let packageBase = plugins.path.join(__dirname,"../");
|
// directories
|
||||||
export let nginxConfigBase = plugins.path.join(packageBase,"nginxconfig/");
|
export const packageBase = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
||||||
export let nginxZoneBase = plugins.path.join(nginxConfigBase,"zones");
|
export const nginxConfigDirPath = plugins.path.join(packageBase, 'nginxconfig');
|
||||||
|
export const nginxHostDirPath = plugins.path.join(nginxConfigDirPath, 'hosts');
|
||||||
|
|
||||||
|
// files
|
||||||
|
export const nginxConfFile = plugins.path.join(nginxConfigDirPath, 'nginx.conf');
|
||||||
|
@ -1,7 +1,21 @@
|
|||||||
import "typings-global";
|
// native
|
||||||
export import cert = require("cert");
|
import * as path from 'path';
|
||||||
export import path = require("path");
|
|
||||||
export import q = require("q");
|
export { path };
|
||||||
export let shelljs = require("shelljs");
|
|
||||||
export import smartfile = require("smartfile");
|
// @pushrocks scope
|
||||||
export import smartstring = require("smartstring");
|
import * as lik from '@push.rocks/lik';
|
||||||
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
|
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, smartfile, smartlog, smartpath, smartpromise, smartshell, smartstring, smartunique };
|
||||||
|
|
||||||
|
// 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,41 +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;
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
11
tsconfig.json
Normal file
11
tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user