Compare commits

..

584 Commits
v1 ... dev

Author SHA1 Message Date
Jacky 0ed7071e8e
chore: prepare for v2.0.0-beta.35 2 years ago
Jacky 2f7070377f
fix: incorrect status of enabled 2fa of user #577 2 years ago
Jacky f2a586ca78
feat: upgrade lego for supporting huaweicloud dns #395 2 years ago
Jacky d1984a06a3
Merge pull request #562 from AnotiaWang/fix/batchupgrader-background 2 years ago
AnotiaWang 7a4fb1daf7 fix: background color of `BatchUpgrader` in dark mode 2 years ago
Jacky f6f66a3b24
docs: update doc 2 years ago
Jacky 46ae1127a2
chore: prepare for v2.0.0-beta.34 2 years ago
Jacky 45048315cd
docs: update documentation about webauthn passkey 2 years ago
Jacky 2f51b5612b
chore: prepare for v2.0.0-beta.34 2 years ago
Jacky f3355eda4f
fix(modify-cert): renewing a cert with dns01 challenge cannot find solver 2 years ago
Jacky b445a1bb69
Merge pull request #555 from 0xJacky/feat/passkey
feat/passkey
2 years ago
Jacky 018a3f15fd
feat: instruction for adding passkey 2 years ago
Jacky aa30b0b4af
Merge branch 'dev' into feat/passkey 2 years ago
Jacky f42a6c2d08
enhance: by default, passkey is used for 2fa if passkey is used to login 2 years ago
WangYK a14f16eeef
fix: background color of `BatchUpgrader` in dark mode (#554) 2 years ago
Jacky 0a6a7693a1
feat: 2fa via passkey 2 years ago
Jacky bdfbbd0e8f
feat: login via passkey 2 years ago
Jacky 44c3180df7
chore: prepare for v2.0.0-beta.33 2 years ago
Jacky cb3599e721
feat: copy secret to register otp #551 2 years ago
Jacky 745e98d1a9
fix: sites not getting enabled on deploy #541 2 years ago
Jacky 796005fad4
fix: unable to recover user from trash or permanently delete them #552 2 years ago
Jacky 53eac765a2
chore: update README.md 2 years ago
dependabot[bot] 86ebed7953
chore(deps): bump vue3-apexcharts from 1.5.3 to 1.6.0 in /app (#533)
Bumps [vue3-apexcharts](https://github.com/apexcharts/vue3-apexcharts) from 1.5.3 to 1.6.0.
- [Commits](https://github.com/apexcharts/vue3-apexcharts/commits)

---
updated-dependencies:
- dependency-name: vue3-apexcharts
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years ago
dependabot[bot] f4f74e3d11
chore(deps): bump @vueuse/integrations from 10.11.1 to 11.0.3 in /app (#523)
Bumps [@vueuse/integrations](https://github.com/vueuse/vueuse/tree/HEAD/packages/integrations) from 10.11.1 to 11.0.3.
- [Release notes](https://github.com/vueuse/vueuse/releases)
- [Commits](https://github.com/vueuse/vueuse/commits/v11.0.3/packages/integrations)

---
updated-dependencies:
- dependency-name: "@vueuse/integrations"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years ago
Jacky be43a6ab20
chore: update dependencies 2 years ago
Jacky ec312c9f28
fix: incorrect version #527 2 years ago
Jacky 2feefbe65e
chore: update dependencies 2 years ago
Jacky 57e82cd3c7
chore: prepare v2.0.0-beta.32 2 years ago
Jacky 4179fad640
fix: fail to save sync_overwrite flag #518 2 years ago
Jacky e93455a302
fix: create config file with an incorrect path #521 2 years ago
Weblate c2e395463b Translated using Weblate (Korean)
Currently translated at 66.0% (315 of 477 strings)

Co-authored-by: jkh0kr <admin@jkh.kr>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/ko/
Translation: Nginx UI/Frontend
2 years ago
Weblate 15f8095b99 Translated using Weblate (Portuguese (Portugal))
Currently translated at 100.0% (477 of 477 strings)

Added translation using Weblate (Portuguese (Portugal))

Co-authored-by: Hintay Lin <hintay@me.com>
Co-authored-by: Kleiser Sarifo <kleiser.sarifo@gmail.com>
Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/pt_PT/
Translation: Nginx UI/Frontend
2 years ago
Weblate 475b1ec088 Translated using Weblate (Japanese)
Currently translated at 17.4% (83 of 477 strings)

Translated using Weblate (Japanese)

Currently translated at 17.4% (83 of 477 strings)

Co-authored-by: Hintay Lin <hintay@me.com>
Co-authored-by: OpenAI <noreply-mt-openai@weblate.org>
Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/ja/
Translation: Nginx UI/Frontend
2 years ago
Hintay eb890652eb
chore: add workflows for synchronize weblate branch 2 years ago
jkh0kr 45766cf117
Change Korean language words from Chinese characters to Hangul (#519)
* Update i18n.json

Change Korean language words from Chinese characters to Hangul

* Update i18n.json

Change Korean language words from Chinese characters to Hangul
2 years ago
Jacky 324a7635cd
chore: prepare for v2.0.0-beta.31 2 years ago
Jacky bc92c0f344
fix: sync config cannot be overwritten #508 2 years ago
Jacky c700a29e17
chore: upgrade go to v1.23.0 2 years ago
Jacky 5d49bda104
fix: radial bar chart style 2 years ago
Jacky 6f6540ace1
chore: prepare v2.0.0-beta.30 2 years ago
Jacky 2cce7849f2
fix: key user does not exist #483 2 years ago
Weblate b0d64e41e0
Translated using Weblate (Japanese)
Currently translated at 16.7% (80 of 477 strings)

Co-authored-by: Hintay Lin <hintay@me.com>
Co-authored-by: OpenAI <noreply-mt-openai@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/ja/
Translation: Nginx UI/Frontend
2 years ago
Weblate 6ab37fa08a Translated using Weblate (Spanish)
Currently translated at 100.0% (477 of 477 strings)

Co-authored-by: Kcho <kcholoren@gmail.com>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/es/
Translation: Nginx UI/Frontend
2 years ago
Weblate d45355e71a Added translation using Weblate (Japanese)
Co-authored-by: Hintay Lin <hintay@me.com>
Co-authored-by: Weblate <noreply@weblate.org>
2 years ago
Hintay bf4d2e8c90
chore: fix ci workflow 2 years ago
Jacky cedcb61fbd
chore: update dependencies 2 years ago
Kcho 7650af1fa2
Updated Spanish dashboard screenshot (#477)
* Added dashboard_es.png

* Update README-es.md
2 years ago
Weblate b147ecc44d Translated using Weblate (Spanish)
Currently translated at 100.0% (477 of 477 strings)

Co-authored-by: Kcho <kcholoren@gmail.com>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/es/
Translation: Nginx UI/Frontend
2 years ago
Hintay 713165f360
Translated using Weblate (Chinese (Traditional))
Currently translated at 100.0% (477 of 477 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (5 of 5 strings)

Co-authored-by: Hintay Lin <hintay@me.com>
Co-authored-by: OpenAI <noreply-mt-openai@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/zh_Hant/
Translation: Nginx UI/Frontend
2 years ago
Kcho 66320c2044
Translated using Weblate (Spanish)
Currently translated at 98.7% (471 of 477 strings)

Co-authored-by: Kcho <kcholoren@gmail.com>
Co-authored-by: Weblate Translation Memory <noreply-mt-weblate-translation-memory@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/es/
Translation: Nginx UI/Frontend
2 years ago
AHTOH 3058f48602
Translated using Weblate (Russian)
Currently translated at 97.2% (464 of 477 strings)

Co-authored-by: AHTOH <k.ahtoh@gmail.com>
Co-authored-by: Weblate <noreply-mt-weblate@weblate.org>
Co-authored-by: OpenAI <noreply-mt-openai@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/ru/
Translation: Nginx UI/Frontend
2 years ago
Jacky 06091651f9
Merge pull request #471 from 0xJacky/dependabot/npm_and_yarn/app/dev/typescript-5.5.4
chore(deps-dev): bump typescript from 5.3.3 to 5.5.4 in /app
2 years ago
dependabot[bot] 89632dcacf
chore(deps-dev): bump typescript from 5.3.3 to 5.5.4 in /app
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.3.3 to 5.5.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.3.3...v5.5.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Jacky 131c0fd5dd
Merge pull request #473 from 0xJacky/dependabot/npm_and_yarn/app/dev/unplugin-auto-import-0.18.2
chore(deps-dev): bump unplugin-auto-import from 0.17.8 to 0.18.2 in /app
2 years ago
dependabot[bot] a0dde8f6d3
chore(deps-dev): bump unplugin-auto-import from 0.17.8 to 0.18.2 in /app
Bumps [unplugin-auto-import](https://github.com/unplugin/unplugin-auto-import) from 0.17.8 to 0.18.2.
- [Release notes](https://github.com/unplugin/unplugin-auto-import/releases)
- [Commits](https://github.com/unplugin/unplugin-auto-import/compare/v0.17.8...v0.18.2)

---
updated-dependencies:
- dependency-name: unplugin-auto-import
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Jacky 3d57f1acc4
Merge pull request #474 from 0xJacky/dependabot/npm_and_yarn/app/dev/vitejs/plugin-vue-jsx-4.0.0
chore(deps-dev): bump @vitejs/plugin-vue-jsx from 3.1.0 to 4.0.0 in /app
2 years ago
Jacky 9a9e4f18f1
Merge pull request #470 from 0xJacky/dependabot/npm_and_yarn/app/dev/unplugin-vue-components-0.27.3
chore(deps-dev): bump unplugin-vue-components from 0.26.0 to 0.27.3 in /app
2 years ago
dependabot[bot] 6200b316b2
chore(deps-dev): bump @vitejs/plugin-vue-jsx from 3.1.0 to 4.0.0 in /app
Bumps [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/HEAD/packages/plugin-vue-jsx) from 3.1.0 to 4.0.0.
- [Release notes](https://github.com/vitejs/vite-plugin-vue/releases)
- [Changelog](https://github.com/vitejs/vite-plugin-vue/blob/main/packages/plugin-vue-jsx/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite-plugin-vue/commits/plugin-vue@4.0.0/packages/plugin-vue-jsx)

---
updated-dependencies:
- dependency-name: "@vitejs/plugin-vue-jsx"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
dependabot[bot] 1013b41001
chore(deps-dev): bump unplugin-vue-components in /app
Bumps [unplugin-vue-components](https://github.com/unplugin/unplugin-vue-components) from 0.26.0 to 0.27.3.
- [Release notes](https://github.com/unplugin/unplugin-vue-components/releases)
- [Commits](https://github.com/unplugin/unplugin-vue-components/compare/v0.26.0...v0.27.3)

---
updated-dependencies:
- dependency-name: unplugin-vue-components
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Hintay Lin 37d5ff3c6c Translated using Weblate (Chinese (Traditional))
Currently translated at 100.0% (5 of 5 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (5 of 5 strings)

Co-authored-by: Hintay Lin <hintay@me.com>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/documents/index/zh_Hans/
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/documents/index/zh_Hant/
Translation: Nginx UI/Index
2 years ago
Hintay 02b4a99160
chore: ignore text file in CodeQL workflow 2 years ago
Hintay 2a03eb7740
fix(ci): no cache and enable run manually for branches.yml 2 years ago
Hintay 43fb701425
enhance: new integration method with Weblate to reduce issues with merging changes 2 years ago
Jacky 6c7b644f60
docs: update docs about insecure skip verify 2 years ago
Jacky f1c0f8ddca
enhance: add settings for skip tls cert check 2 years ago
Jacky 013d810678
fix: uncontrolled data used in path expression 2 years ago
Jacky 226827f21e
chore: update vue-tsc to v2 2 years ago
Jacky cd0c79cfdf
Merge pull request #462 from 0xJacky/dependabot/go_modules/github.com/sashabaranov/go-openai-1.27.1
chore(deps): bump github.com/sashabaranov/go-openai from 1.27.0 to 1.27.1
2 years ago
Jacky aece83403c
chore(deps): change the registry of vue-github-button 2 years ago
Hintay 8da309bb88
chore: add target branch for dependabot 2 years ago
dependabot[bot] e485dd3fac
chore(deps): bump github.com/sashabaranov/go-openai
Bumps [github.com/sashabaranov/go-openai](https://github.com/sashabaranov/go-openai) from 1.27.0 to 1.27.1.
- [Release notes](https://github.com/sashabaranov/go-openai/releases)
- [Commits](https://github.com/sashabaranov/go-openai/compare/v1.27.0...v1.27.1)

---
updated-dependencies:
- dependency-name: github.com/sashabaranov/go-openai
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Jacky ea354789d3
Merge pull request #458 from 0xJacky/feat/codeql
feat: create codeql.yml
2 years ago
Jacky 3bd70475ef
feat: create codeql.yml 2 years ago
Jacky 85d74932a0
fix: dependabot.yml 2 years ago
Jacky 581efa89f9
Merge pull request #455 from 0xJacky/feat/dependabot
feat: create dependabot.yml
2 years ago
Jacky e2a3611f57
feat: create dependabot.yml 2 years ago
Jacky 83981349d7
enhance: 2FA is no longer required for the first 3min of login 2 years ago
Hintay 53c57b2d3d
refactor: single-file versioning 2 years ago
Hintay e3b0c392ab
chore: fix branches workflow 2 years ago
Weblate e65ce0d87e Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
2 years ago
Jacky 4d088f6a44
chore: update dependencies 2 years ago
Jacky e72e8cef57
enhance(upgrader): restart main proc manually and gracefully 2 years ago
Hintay 31bbab71c9
chore: add workflow for main branch auto merge 2 years ago
Jacky 3a035e9930
chore: update deps 2 years ago
Jacky a0e3d1ee91
style: change indent of yml 2 years ago
Jacky e9aa8d3e9d
chore: add translated status on readme.md 2 years ago
Jacky 40d6a07514
chore: prepare v2.0.0-beta.29 2 years ago
Jacky 11c733547f
feat: save settings required 2fa if enabled otp 2 years ago
Jacky d0af8bd427
Merge pull request #452 from 0xJacky/refactor/config
chore: update translations
2 years ago
Jacky e8d160d713
chore: update translations 2 years ago
Jacky 26827b5114
Merge pull request #451 from 0xJacky/refactor/config
refactor: config management
2 years ago
Jacky c9370a0562
feat: update notification template for config sync 2 years ago
Jacky 1c1da92363
feat: deploy config to remote nodes #359 2 years ago
Jacky e75dce92ad
chore: update translations 2 years ago
Jacky ace8d7a0fe
feat: rename folder or file in configurations list 2 years ago
Jacky 5dd2c8f931
feat: better breadcrumbs for config list and editor; add filename filter for configurations list. 2 years ago
Jacky 53ae1a1ef9
refactor: config management 2 years ago
Jacky eb9ede5a4e
fix: back btn of config list unable to return to the previous page 2 years ago
Jacky 7646b87da0
chore: prepare v2.0.0-beta.28 2 years ago
Jacky 106397ed27
chore: update translations 2 years ago
Jacky e05d91e8b3
fix: node selector styles broken in medium width screen 2 years ago
Jacky 4660a46a7e
refactor: auto certificate options
1. Add OCSP Must Staple options #292
2. Add LEGO_DISABLE_CNAME_SUPPORT options #407
2 years ago
Jacky 532d6e83c5
refactor: better breadcrumbs #258 2 years ago
Jacky b9c7d1d001
fix(configs): spinning constantly in table if dir has no file 2 years ago
Jacky 2d6fa63964
enhance: show the info of changed certificates #386 2 years ago
Jacky e1a5521f4a
feat: display info of multiple certificates in server tab. 2 years ago
Jacky ada02323d8
refactor(change_cert): support select multiple certificates #437 2 years ago
Jacky 2b6e84ab62
feat: hide some parts of jwt secret and node secret 2 years ago
Weblate 45a136380d Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
2 years ago
Jacky a48fde8be3
fix: style of input recovery code in 2fa settings 2 years ago
Jacky 08ed0693ca
Merge pull request #447 from 0xJacky/feat/2fa
[Feature] Two Factor Authorization
2 years ago
Jacky bcff00c47b
feat: disable enroll 2fa in demo mode 2 years ago
Jacky 46e78f4405
chore: update docs 2 years ago
Jacky afd6bf4268
fix: do not popup otp modal if user not enable 2fa 2 years ago
Jacky b68e8a1403
enhance: do not require 2fa in 2min 2 years ago
Jacky a5dda59ad5
chore: update translations 2 years ago
Jacky 3a22861640
feat: 2FA authorization for web terminal 2 years ago
Jacky 802d05f692
chore: update translations 2 years ago
Jacky 5abd9b75bb
feat: login 2fa 2 years ago
Jacky 8d8ba150ef
fix: save settings error #446 2 years ago
Jacky 42cd7093a9
feat: hidden env management page and upgrade page when connect to remote node 2 years ago
Jacky 852838a521
chore: prepare v2.0.0-beta.27 2 years ago
Jacky 3a600be3b3
Merge pull request #442 from 0xJacky/enhance/ota
Enhance/ota
2 years ago
Jacky d389bb07ae
feat: batch upgrade nginx-ui on remote nodes #424. 2 years ago
Weblate 01644ccd19 Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
2 years ago
Jacky da682cc3d6
Merge pull request #445 from PeterWang-dev/bugfix/correct-stream-conf
Bugfix/Correct stream conf
2 years ago
PeterWang-dev 7c21aa2377 fix(resources): remove trailing `.conf` in default nginx stream block
Fix #444
2 years ago
Jacky f5a0a9ed50
enhance(upgrader): gracefully replace the old exe with the new exe 2 years ago
Jacky 7ef4fec896
fix: cannot ota upgrade when connect to remote node #424 2 years ago
Jacky f41b6bc07b
chore: prepare v2.0.0-beta.26 2 years ago
Jacky 43c5419fc6
chore: update deps 2 years ago
Jacky fb2ea7ec7d
Merge pull request #439 from 0xJacky/enhance/login
Enhance/login
2 years ago
Jacky 743daaa56f
chore(docs): update docs about auth settings 2 years ago
Jacky cff843b82b
feat: add login failed ban ip list 2 years ago
Jacky ccb04c07d8
enhance: handle websocket error 2 years ago
Jacky 204ffaed6d
Merge pull request #440 from 0xJacky/enhance/handle-ws-error 2 years ago
Jacky ff1399e044
enhance: handle websocket error 2 years ago
Jacky d6b22c157c
chore: update docs of auth 2 years ago
Jacky 3b937ee0f4
feat: add ip whitelist 2 years ago
Jacky 7a9aa3a33b
chore: update lego configurations 2 years ago
Jacky 7f3f23d706
feat: add gpt-4o-mini model 2 years ago
Jacky 1722d74670
Merge pull request #436 from 0xJacky/dependabot/go_modules/google.golang.org/grpc-1.64.1
chore(deps): bump google.golang.org/grpc from 1.64.0 to 1.64.1
2 years ago
dependabot[bot] b69872dd50
chore(deps): bump google.golang.org/grpc from 1.64.0 to 1.64.1
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.64.0 to 1.64.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.64.0...v1.64.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Jacky f8c3ced1d9
fix(template): $proxy_add_forwarded not defined in reverse_proxy.conf 2 years ago
Jacky 7fb84597cf
Merge pull request #433 from wcbing/patch-1
fix: http-to-https use $host and 308
2 years ago
炳 ff7e3e79ca
fix: http-to-https use 301 2 years ago
炳 bd6609226b
fix: http-to-https use $host and 301 2 years ago
Jacky ce7d95210d
fix: eslint error in radial bar chart 2 years ago
Jacky 24cf21b18a fix: radial bar chart style broken in 1.3k-1.7k px window 2 years ago
Jacky 7d5104e550
fix: radial bar chart style broken in 1.3k-1.7k px window 2 years ago
Weblate 6f349aa12a Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
2 years ago
Jacky 9aac7c2e4c
fix(demo): recreate access.log and error.log as regular files 2 years ago
Jacky 65befe282b
fix: update cert model bug 2 years ago
Jacky 47d4013f3d
Merge pull request #420 from 0xJacky/enhance/auto-cert
Enhance auto cert
2 years ago
Jacky 217f4dc417
chore: prepare v2.0.0-beta.25 2 years ago
Jacky b3486a42a5
feat: sync certificates to remote server #293, #363, #411 2 years ago
Jacky 11e460765a
fix: certificate dir cannot be created in some windows-docker setup #403 2 years ago
Jacky 805934567a
fix: maybe fail to get get default ca dir #417 2 years ago
Jacky 993e4a903d
Merge pull request #416 from 0xJacky/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/azidentity-1.6.0
chore(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity from 1.5.2 to 1.6.0
2 years ago
dependabot[bot] 59024f57a3
chore(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity
Bumps [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) from 1.5.2 to 1.6.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/internal/v1.5.2...sdk/azcore/v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Jacky a3659017a2
chore: update deps 2 years ago
Jacky 80a8b1de97 fix: missing provider in dns credential viewer 2 years ago
Jacky cb303bad7e feat: enable search box for ace editor #412 2 years ago
Jacky 020a9ba2f2
feat: enable search box for ace editor #412 2 years ago
Weblate c8502ad7bf Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
3 years ago
Jacky 0e3a824c11
Merge pull request #402 from 0xJacky/feat/beta.24
Feat/beta.24
3 years ago
Jacky f52c84ea21
chore: prepare v2.0.0-beta.24 3 years ago
Jacky 538be53e9c
fix: renewed certificate and private key not save #391 3 years ago
Jacky c1c1094544
chore(reverse_proxy.conf): support rfc7239 # 306 3 years ago
Jacky 6302454826
fix: safety text validate rule #383 3 years ago
Jacky 189f623994
feat: add gpt-4o model 3 years ago
Jacky 7ce0c1f951
enhance: update reverse_proxy.conf #389 3 years ago
Jacky 0d5a1f3a8c
fix: demo nginx config 3 years ago
Jacky 191b6bae10
chore: update demo.db 3 years ago
Jacky 931f7a8737
fix: proxy url query unescape issue #377 3 years ago
Jacky d6d7cdbb1f
fix: environment list query issue 3 years ago
Jacky 392cac4186
chore(docs): add env reference 3 years ago
Jacky c18f8f0b27
fix: auto cert nil ptr issue 3 years ago
Jacky 621772bafa
chore: update translations 3 years ago
Jacky 1ac1d150c0
Merge pull request #376 from 0xJacky/docker/s6-overlay
Enhance nginx ui docker image
3 years ago
Jacky e0366f949f
feat: reload cluster node settings from settings file #169 3 years ago
Jacky 29f1b7db89
chore(docs): update documentations 3 years ago
Jacky 9a13ee601c
chore: prepare v2.0.0-beta.23 3 years ago
Jacky a689608bdb
feat: use settings file to predefine nodes #169 3 years ago
Jacky b429c15893
feat: add enabled/disabled field to environment model #169 3 years ago
Jacky cc5d2be1bd
chore: update dependencies 3 years ago
Jacky 1e9de6f21b
feat: customize local environment name #313 3 years ago
Jacky 4c74bc8619
feat: use env to predefine admin user #214 3 years ago
Jacky 13c4eb04a3
feat: add env to skip installation #357 3 years ago
Jacky cb0fb47e1c
feat: use env to override settings 3 years ago
Jacky a82ad2aea4
Merge branch 'dev' into docker/s6-overlay 3 years ago
Jacky d4fbeef498
chore(docs): update backend build command 3 years ago
Jacky 2071891841
fix: certificate selector can not select #375 3 years ago
Jacky 9413978697
fix: build ldflags 3 years ago
Weblate f0dafa79f2
Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
3 years ago
Jacky 8623e1e89b
fix: certificate selector can not select #375 3 years ago
Jacky ee30e840e3
chore(demo): update dockerfile 3 years ago
Jacky 7669e34b62
chore(docs): update nginx log document 3 years ago
Jacky abc73bbf77
enhance(docker): recreate access.log and error.log as regular files 3 years ago
Jacky 45a68112b1
fix(docker): nginx restart always output network error 3 years ago
Jacky 070c0b4620
feat(docker): mkdir streams-enabled, streams-available 3 years ago
Jacky 9bd1507392
feat(docker): integrate s6-overlay 3 years ago
Jacky bd0bbe95ef
fix: build ldflags 3 years ago
Weblate be784a4a88 Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
3 years ago
Jacky 02d279fa97
fix(docs): nginx config section 3 years ago
Jacky 4f06d80a2e
fix: typo error 3 years ago
Jacky 92fced15db
chore: prepare for v2.0.0-beta.22 3 years ago
Jacky 1bf72009dc
chore: update app.example.ini 3 years ago
Jacky 7ee7b12cac
chore(docs): rm .yarnrc.yml 3 years ago
Jacky 4ad5e77fd3
feat(docs): add options descriptions for server settings 3 years ago
Jacky 7be4a70824
feat: add recursive nameservers settings for dns challenge #372 3 years ago
Jacky d3e9d92750
fix(acme_user_selector): handle acme users list pagination 3 years ago
Jacky dd56fecc53
chore: update softprops/action-gh-release to v2 3 years ago
Jacky 660f11a50e
chore: prepare v2.0.0-beta.21 3 years ago
Jacky be5eae0df9
fix: obtain certificate issue #368 3 years ago
Jacky 49a0c6fa87
chore: prepare v2.0.0-beta.20 3 years ago
Jacky d0924eb4ae
fix: authorization failed when link start to a wrong environment #342 3 years ago
Jacky 1e9c537bdb
Merge pull request #364 from 0xJacky/enhance/chatbot 3 years ago
Jacky 405fdb7c34
chore: update translations 3 years ago
Jacky 642e21a260
enhance: chat with LLM 3 years ago
Weblate 2ee82e774b Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
3 years ago
Jacky e84ea98be9
chore: update translations 3 years ago
Jacky 3b116b3654
feat(chat): support other local llm #331 3 years ago
Jacky 08631437ee
fix: nginx guide link #201 3 years ago
Jacky cfa7629c30
Merge pull request #361 from 0xJacky/refresh-24.04
refactor: refresh webui and certificates module
3 years ago
Jacky a0013b5cef
chore: prepare v2.0.0-beta.19 3 years ago
Jacky 7d22e86f35
chore: update translations 3 years ago
Jacky e16b077d20
feat: using renewal api to renew certificate #319 3 years ago
Jacky e3876cffaf
enhance: limit cert renewal interval between 7 to 21 days 3 years ago
Jacky 49b41d6eb7
feat: support not-only Let's Encrypt service #16 3 years ago
Jacky 3e90b838fd
feat: SSL management support different types of certificates of a same doamin name #309 3 years ago
Jacky 464e84a64f
feat: add key type column for certificate list 3 years ago
Jacky f0dcd67004
feat: add a option to select a acme user when obtaining a certificate. 3 years ago
Jacky e77d37bbaa
feat: set renewal interval of certificates #343 3 years ago
Jacky 4c7e037b76
refactor: refresh webui 3 years ago
Jacky 59d59dd3ed
feat: add dns providers links #336
Close #336
3 years ago
Jacky 376e2a76d1
chore: update lego config 3 years ago
Jacky b60d6096fa
chore: update deps 3 years ago
Jacky 4e52563d59
Merge pull request #355 from 0xJacky/dependabot/go_modules/golang.org/x/net-0.23.0
chore(deps): bump golang.org/x/net from 0.20.0 to 0.23.0
3 years ago
dependabot[bot] 386c927791
chore(deps): bump golang.org/x/net from 0.20.0 to 0.23.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.20.0 to 0.23.0.
- [Commits](https://github.com/golang/net/compare/v0.20.0...v0.23.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
Jacky ab96e9c54d
Merge pull request #347 from 0xJacky/dependabot/npm_and_yarn/app/vite-5.1.7
chore(deps-dev): bump vite from 5.1.6 to 5.1.7 in /app
3 years ago
Jacky 5a8b3902d3
Merge pull request #345 from 0xJacky/dependabot/npm_and_yarn/docs/vite-5.2.8
chore(deps): bump vite from 5.1.3 to 5.2.8 in /docs
3 years ago
dependabot[bot] 9aaeff2fc3
chore(deps-dev): bump vite from 5.1.6 to 5.1.7 in /app
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.1.6 to 5.1.7.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.1.7/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.1.7/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
dependabot[bot] 91d566a377
chore(deps): bump vite from 5.1.3 to 5.2.8 in /docs
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.1.3 to 5.2.8.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.2.8/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
Jacky 4289d55562
chore: update lego configs 3 years ago
Jacky aeed27a2fa
chore(deps): bump follow-redirects from 1.15.5 to 1.15.6 in /app 3 years ago
dependabot[bot] 67b60a620f
chore(deps): bump follow-redirects from 1.15.5 to 1.15.6 in /app
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.5 to 1.15.6.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.5...v1.15.6)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
Jacky 979a1d5326
fix: PKCS8 format private key validating issue #326 3 years ago
Jacky 1577eb184d
revert: add must staple flag for certificate obtaining request #292 3 years ago
Jacky 1cdd2f9830
chore(deps): bump google.golang.org/protobuf from 1.32.0 to 1.33.0 3 years ago
dependabot[bot] 645d6c4fbf
chore(deps): bump google.golang.org/protobuf from 1.32.0 to 1.33.0
Bumps google.golang.org/protobuf from 1.32.0 to 1.33.0.

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
Jacky 744f8bc93b
chore(deps): bump github.com/go-jose/go-jose/v3 from 3.0.1 to 3.0.3 3 years ago
Jacky 4b277cf3c1
fix: stream is not deleted actually 3 years ago
倪天华 7b25eb4d27 fix: stream is not deleted actually 3 years ago
dependabot[bot] bef697b098
chore(deps): bump github.com/go-jose/go-jose/v3 from 3.0.1 to 3.0.3
Bumps [github.com/go-jose/go-jose/v3](https://github.com/go-jose/go-jose) from 3.0.1 to 3.0.3.
- [Release notes](https://github.com/go-jose/go-jose/releases)
- [Changelog](https://github.com/go-jose/go-jose/blob/v3.0.3/CHANGELOG.md)
- [Commits](https://github.com/go-jose/go-jose/compare/v3.0.1...v3.0.3)

---
updated-dependencies:
- dependency-name: github.com/go-jose/go-jose/v3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
klic-infra 71445a8a88 Translated using Weblate (Korean)
Currently translated at 84.0% (305 of 363 strings)

Co-authored-by: klic-infra <github_infra@klic.co.kr>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/ko/
Translation: Nginx UI/Frontend
3 years ago
Weblate 55f688900a Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
3 years ago
Jacky cbe4da76cd fix: include directive not load content #314 3 years ago
Jacky 1d6e61c744 chore(ci): add trigger paths for building action 3 years ago
Jacky 8965edb0b4 feat: add ko_KR translations by @klic-infra 3 years ago
Jacky 7640c1fdc3 enhance: dynamic translation module 3 years ago
Jacky c8cd3e6186 chore: prepare v2.0.0-beta.18 3 years ago
Jacky 0fa98703cd feat: logrotate cron task for docker users #255 3 years ago
Jacky b7f50f0053 revert: use dev container 3 years ago
Jacky b61534ebfe feat: use dev container 3 years ago
Jacky 0d140b41da fix: sort order 3 years ago
Jacky b1e95d30f1 perf(ci): build docs on macos-14 3 years ago
Jacky 0a24469248 fix(docs): redirect to target lang show 404 3 years ago
Jacky 9ed10d65ba chore: update readme.md 3 years ago
Jacky fcf625f55e
fix: errors of ru_RU translations 3 years ago
AHTOH cde3732ca6
Update app.po
Fix error
3 years ago
Jacky 8d9e763503
chore: update ru_RU translations 3 years ago
AHTOH 17e511a2e5
Update app.po
Minor fixes and additions
3 years ago
Jacky 36e6ec555a chore: prepare v2.0.0-beta.17 3 years ago
Jacky fdaa11872a fix: log path error caused by multi log params #301
close #301
3 years ago
Jacky 99da617d61 chore: temporarily lock vue version to 3.4.17 #295
close #295
3 years ago
Jacky 1c4fb7afcc feat: add must staple flag for certificate obtaining request #292 3 years ago
Jacky c66250532e fix(docs): wrong explain of port mapping of docker command #289, #278
close #289, #278
3 years ago
Jacky 371adde8b6 chore: prepare v2.0.0-beta.16 3 years ago
Jacky 97ec26331b fix: wildcard certificate challenge method not present 3 years ago
Jacky f727218a28 chore: prepare v2.0.0-beta.15 3 years ago
Jacky 547aeeadd3 chore: update translations 3 years ago
Jacky 22d62e420b feat: configurable cert key type #264 3 years ago
Jacky a095c88fd2 fix: log container is empty after failing to obtain cert #281 3 years ago
0xJacky fd519aea5e
chore(deps): upgrade vite to v5.1 3 years ago
0xJacky c3b22c1b27
feat(docs): check browser language 3 years ago
0xJacky 9be508c976
chore: update cosy 3 years ago
0xJacky e12e83c90a
Merge branch 'dev' of github.com:0xJacky/nginx-ui into dev 3 years ago
0xJacky e3b1bfbf50
chore: build with go 1.22.0 3 years ago
Weblate 1338182b86 Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
3 years ago
Jacky 3bbe56cdc4
chore: prepare v2.0.0-beta.14 3 years ago
0xJacky 66571bc1d4
chore: prepare v2.0.0-beta.14 3 years ago
0xJacky 2526d71c0e
fix: unable to create a certificate from a second environment #273 3 years ago
0xJacky abe43c5c4d
fix: symbol links are not displayed in config list #272 3 years ago
0xJacky 371472e67b
fix: parse ssl certificate error #270 3 years ago
Jacky 4e369baddb
perf(ci): use macos runner to build vite (#274) 3 years ago
0xJacky e1c38e28a8
perf(ci): use macos runner to build vite 3 years ago
Kcho 4eb32538db Translated using Weblate (Spanish)
Currently translated at 100.0% (355 of 355 strings)

Co-authored-by: Kcho <kcholoren@gmail.com>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/es/
Translation: Nginx UI/Frontend
3 years ago
Weblate 43f07cc98f Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
3 years ago
0xJacky da2c6d83d6
fix: openai model validator 3 years ago
0xJacky db832d045b
chore: prepare v2.0.0-beta.13 3 years ago
0xJacky 1950d9a86a
fix(upgrader): github proxy for downloading digest 3 years ago
0xJacky de8d6073a3
chore(ci): remove duplicated cache restore action 3 years ago
0xJacky a798b2cce9
chore(ci): update actions plugin to use node 20 3 years ago
0xJacky 741ffa14b0
chore(ci): update actions to use node.js 20 3 years ago
WangYK 4c1112c023
fix: directive editor background and `Modal` in dark mode (#267) 3 years ago
Weblate e247471d5b Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
3 years ago
0xJacky 33b9c1a4f3
chore(ci): upgrade actions/download-artifact 3 years ago
0xJacky f03756ad8a
chore(ci): update actions to use node.js 20 3 years ago
0xJacky 0381d2290c
chore: update zh_CN translations 3 years ago
0xJacky 398eea2159
enhance: show the form error details of Preference 3 years ago
0xJacky b0a3989ef4
enhance: show the form error details of CertificateEditor 3 years ago
0xJacky 8581bdd3c6
enhance: validate certificate content before save 3 years ago
0xJacky d67b8428e4
enhance: validate settings value before save 3 years ago
0xJacky d70e37c857
fix: taking 100% CPU if the log file is not a regular file 3 years ago
dependabot[bot] f20d97a9fd
chore(deps-dev): bump vite from 5.0.11 to 5.0.12 in /app (#262)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.11 to 5.0.12.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.0.12/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.0.12/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
dependabot[bot] 140cd170ed
chore(deps): bump vite from 5.0.11 to 5.0.12 in /docs (#263)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.11 to 5.0.12.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.0.12/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.0.12/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
0xJacky 40a17d0e72
fix(docs): translation issue in guide/nginx-ui-template.md 3 years ago
0xJacky 49f70bc9e9
chore: bump nginx-ui version to v2.0.0-beta.11 3 years ago
0xJacky 1658e4b5a3
enhance: skip the directives validation check of gonginx 3 years ago
0xJacky 99d6983924
chore: update screenshots 3 years ago
0xJacky d5c7d7afe8
docs: documentation for v2 3 years ago
0xJacky a66bc142dd
docs: zh_TW documentation for v2 3 years ago
0xJacky 81db62b5ba
docs(wip): english documentation for v2 3 years ago
0xJacky 2d52ada657
docs(wip): documentation for v2 3 years ago
0xJacky 712a4d2185
fix: styles of installation page 3 years ago
Weblate e7d394b73b Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
3 years ago
0xJacky 526fedd04a
enhance(cosy): pagination list 3 years ago
0xJacky 79d0d37526
fix(template): syntax error in codeigniter.conf 3 years ago
0xJacky 70c89b794e
fix: unknown directive '' 3 years ago
0xJacky e093d9276c
fix: tsx type errors 3 years ago
0xJacky 85da74b3f0
enhance: update gonginx and cosy to latest version 3 years ago
dependabot[bot] af9395ad69
chore(deps): bump follow-redirects from 1.15.3 to 1.15.4 in /app (#251)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.3 to 1.15.4.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.3...v1.15.4)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
dependabot[bot] a03ef576bd
chore(deps): bump github.com/go-resty/resty/v2 from 2.10.0 to 2.11.0 (#250)
Bumps [github.com/go-resty/resty/v2](https://github.com/go-resty/resty) from 2.10.0 to 2.11.0.
- [Release notes](https://github.com/go-resty/resty/releases)
- [Commits](https://github.com/go-resty/resty/compare/v2.10.0...v2.11.0)

---
updated-dependencies:
- dependency-name: github.com/go-resty/resty/v2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
Kcho 53cedb56da Translated using Weblate (Spanish)
Currently translated at 86.7% (301 of 347 strings)

Co-authored-by: Kcho <kcholoren@gmail.com>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/es/
Translation: Nginx UI/Frontend
3 years ago
Weblate 667594bdd4 Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
3 years ago
Eddie ab7b137074
chore: update hotlink-protection.conf (#246) 3 years ago
Eddie e945de0309
chore: update enable-php-8.conf (#245)
增加繁體
3 years ago
Eddie 7f9f06dfbf
chore: update codeigniter.conf (#244) 3 years ago
0xJacky 68afb7e7e8
feat: get data from db after modify 3 years ago
0xJacky 626196a239
chore: replace ghproxy.com with mirror.ghproxy.com 3 years ago
0xJacky 5a19133254
enhance(cosy): permanently delete 3 years ago
0xJacky 6d5f34751d
fix(cosy): ensure the list sort query is validated to prevent SQL injection 3 years ago
0xJacky 18f2b4aba8
chore: rm unused functions in model.go 3 years ago
0xJacky 38c9727e15
chore: bump nginx-ui version to v2.0.0-beta.9 3 years ago
Hintay ec93ab05a3
fix: ensure the list sort query is validated to prevent SQL injection
Credits to @jorgectf for the advisories.
3 years ago
Hintay 827e76c46e
fix: add protected fields to settings to mitigate high-severity vulnerability
Credits to @jorgectf for the advisories.
3 years ago
dependabot[bot] 0a9e23daf4
chore(deps): bump golang.org/x/crypto from 0.16.0 to 0.17.0 (#241)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.16.0 to 0.17.0.
- [Commits](https://github.com/golang/crypto/compare/v0.16.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
0xJacky 0a1ac06266
chore: update dependencies 3 years ago
0xJacky f2f2ee1379
style: responsive design for NodeAnalytic in dashboard 3 years ago
0xJacky a63e85aa37
chore: update code styles for upstream.go 3 years ago
0xJacky 9a18005eae
enhance: do not test availability if not socket 3 years ago
0xJacky 591486a689
fix: read properties of null in NodeSelector 3 years ago
0xJacky 53e1c32444
fix: websocket of upstream availability test not close 3 years ago
0xJacky dfee30e9d9
chore: bump nginx-ui version to v2.0.0-beta.8 3 years ago
0xJacky fc0895fe62
chore: update demo.db 3 years ago
0xJacky 6c8bfd267a
fix: ChatGPT messages history for stream 3 years ago
0xJacky 2649b710bb
feat: introducing streams management pages #166 3 years ago
0xJacky 9c16b55dde
fix: eslint errors 3 years ago
0xJacky 384c2ae8aa
chore: update nginx config for demo 3 years ago
0xJacky d9d8bee5d0
feat: upstream health check #166 3 years ago
0xJacky b2854d4965
feat(wip): collapsible panel for NgxConfigEditor 3 years ago
0xJacky 43074728bf
feat(wip): upstream editor #138 3 years ago
0xJacky aec519499f
fix: combine request for StdSelector init 3 years ago
0xJacky 04bf8ec487
chore: bump nginx-ui version to v2.0.0-beta.7 3 years ago
0xJacky a7e523b47b
feat: support wildcard certificate #190 3 years ago
0xJacky 4984771c7d
chore: update zh_CN translations for templates 3 years ago
Sanvu88 9a6900b07f
feat: add some Nginx Config Templates (#233) 3 years ago
0xJacky 17d6216e36
fix: maybe error when enable TLS #230
close #230
3 years ago
0xJacky d1cbc72044
fix: resolve antdv build warning 3 years ago
0xJacky 013dc0bd52
enhance: removed the required rules of DNS Credentials #231 3 years ago
0xJacky 9d62b3ef03
refactor(cosy): cosy directory structure 3 years ago
0xJacky 40ca44d183
chore: update frontend build commands 3 years ago
0xJacky 33039f0195
fix: current_server_directives.splice is undefined 3 years ago
0xJacky d2ba3ebad3
feat(vite): add env config for proxy target 3 years ago
Sanvu88 0e8798cd90
fix: Not load Vietnamese when select from menu (#229) 3 years ago
Buco d4d5bd41c2
fix: AccessLogPath being replaced by PIDPath (#228) 3 years ago
Sanvu88 0a4c1cd1ac
chore: add README file in Vietnamese (#226) 3 years ago
Jacky ce7ccb6d4c
chore: add Vietnamese language 3 years ago
sanvu88 b19b9cfe9e Add Vietnamese language 3 years ago
0xJacky 0e28506bdd
chore: bump nginx-ui version to v2.0.0-beta.6 3 years ago
0xJacky 179995c4b0
feat: auto detect nginx log path 3 years ago
0xJacky f7d9f2564f
enhance: nginx control 3 years ago
0xJacky 30f75ff7cd
fix: eslint errors 3 years ago
Jacky 7c6b4fec91
fix: nginx control failure 3 years ago
0xJacky 6fa90a15e4
enhance: find out the highest log level of nginx 3 years ago
0xJacky b6cbc34e6f
fix: fail to control nginx 3 years ago
Jacky fcf789e271
chore(deps-dev): bump vite from 5.0.4 to 5.0.5 in /app 3 years ago
Jacky c068d4b8a4
chore(deps): bump vite from 5.0.2 to 5.0.5 in /docs 3 years ago
dependabot[bot] 3035d32676
chore(deps-dev): bump vite from 5.0.4 to 5.0.5 in /app
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.4 to 5.0.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.0.5/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
dependabot[bot] 582852f6e9
chore(deps): bump vite from 5.0.2 to 5.0.5 in /docs
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.2 to 5.0.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.0.5/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
0xJacky 26788f301f
fix: ngx_directives not update #218 3 years ago
0xJacky 4bab7b243d
fix: english grammar error #200 3 years ago
0xJacky f6712a80bb
chore: bump nginx-ui verison to v2.0.0-beta.5 3 years ago
0xJacky 994b9087ae
feat: add notifications for renew certs #192 3 years ago
0xJacky ddb6cee153
fix: rm duplicated delete button 3 years ago
0xJacky ac68fd05c9
refactor(cert): introducing new management page
1. User can now view the latest renew logs of the certain certificate.

2. Add manually renew button in certificate modify page for managed certificate (auto cert)
3 years ago
0xJacky 7c47f08a72
fix(template): clientMaxBodySize name is wrong #216 3 years ago
0xJacky ca683f9c7f
refactor: resolve footer-toolbar hidden by monica #195 3 years ago
0xJacky a49d9e0037
refactor: resolve footer-toolbar hidden by monica #195 3 years ago
0xJacky 5b3cd981e9
feat: change challenge method in certificate management page 3 years ago
0xJacky 002d9c22ab
fix: document.tile is not translated 3 years ago
0xJacky c783b962ac
fix: certificate vaild time check 3 years ago
0xJacky fc4b503952
chore(deps): update vite-plugin-build-id 3 years ago
0xJacky 8d75e1750d
chore(deps): update vite-plugin-build-id 3 years ago
0xJacky 6dd0ec46a3
chore: add type define for casdoor module 3 years ago
0xJacky 37fa8b899f
refactor: casdoor settings 3 years ago
0xJacky ed72b67300
fix: lint error 3 years ago
0xJacky b955e84668
fix: build error 3 years ago
0xJacky 3098af113c
fix: warning during vite build except that of antd 3 years ago
Jacky dcdd87ac1b
fix: build error caused by writeFileSync in node 21.3 3 years ago
0xJacky 33f64ffee9
chore: rm redundant imports 3 years ago
0xJacky baa4c08264
fix: build warning caused by a constant value in SideBar.vue 3 years ago
0xJacky 55c17a674e
fix: vite-plugin-build-id 3 years ago
0xJacky 7a94734d99
fix(ci): fix nodejs writeFileSync panic 3 years ago
0xJacky 14903b6aa6
fix(ci): set node version to 21.2 3 years ago
0xJacky 2679527cce
fix(style): dark mode style 3 years ago
0xJacky 4e85d72e96
chore: update translations 3 years ago
Jacky 9524e89c17
refactor: refactor app and api 3 years ago
0xJacky 23b39a80ab
feat(ci): check app code style and types 3 years ago
0xJacky ab1adcfa3d
fix: resolved all vue-tsc errors 3 years ago
0xJacky d325dd7493
fix: resolved eslint errors 3 years ago
0xJacky 287ef7527d
refactor: refactor app and api 3 years ago
AHTOH 5ab50b8a93
chore: update app.po (#210)
Locale update and bug fixes
3 years ago
0xJacky 60798b5f4a
feat(app): use tailwind css 3 years ago
0xJacky b475d8b609
fix: auto certificate may be blocked by errors #182 3 years ago
0xJacky 50b4fbcda4
refactor: structure of api-router directory 3 years ago
0xJacky d272f7900f
chore(deps): update dns challenges toml 3 years ago
0xJacky 45c4b130ff
chore(deps): upgrade gomarkdown 3 years ago
0xJacky 087a93d5fb
chore: update zh_CN translations 3 years ago
0xJacky 6993cc67e3
fix: delete server confirm model not destroy #206
close #206
3 years ago
0xJacky 98e08786b0
fix(ci): docs build error 3 years ago
0xJacky 50dc75eb22
fix: docs build error 3 years ago
0xJacky 8aa9363bbe
fix: build error 3 years ago
0xJacky e5a5889931
refactor: project directory structure 3 years ago
0xJacky c1193a5b8c
fix(app): layout height 3 years ago
0xJacky 91817a3a32
fix: buttons disappear when monica opened #195 3 years ago
0xJacky 500998b49f
feat: add config inspection to sites list #198 3 years ago
0xJacky 867669cb90
fix: build error 3 years ago
0xJacky 831e90b14b
enhance: error handler for execShell 3 years ago
0xJacky 08bfa6b221
chore(ci): replace yarn with pnpm 3 years ago
0xJacky d84dbffb54
refactor: upgrade ant design vue v3 to v4 3 years ago
Jray c578f26054
fix: unauthorized access (#205) 3 years ago
Jray 7fe3517afe
feat: added casdoor sso support (#204) 3 years ago
leic4u 34289150fa
chore: update README.md (#202)
Fix some mistakes
3 years ago
0xJacky 9a4174e6ef
fix: revert enable site if enable a incorrect config #199 3 years ago
0xJacky 4b567e474c
fix: nginx logs manual link error #201
close #201
3 years ago
0xJacky 7aa1765dda
Merge branch 'dev' of github.com:0xJacky/nginx-ui into dev 3 years ago
0xJacky 1fa90acc3e
fix: english grammar error #200
close #200
3 years ago
dependabot[bot] 9bdedc0151
chore(deps): bump github.com/go-jose/go-jose/v3 from 3.0.0 to 3.0.1 (#196)
Bumps [github.com/go-jose/go-jose/v3](https://github.com/go-jose/go-jose) from 3.0.0 to 3.0.1.
- [Release notes](https://github.com/go-jose/go-jose/releases)
- [Changelog](https://github.com/go-jose/go-jose/blob/v3/CHANGELOG.md)
- [Commits](https://github.com/go-jose/go-jose/compare/v3.0.0...v3.0.1)

---
updated-dependencies:
- dependency-name: github.com/go-jose/go-jose/v3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
leic4u 04a61c6200
chore: update README.md (#194)
1. Add some badge for Github and Docker.
2. Update usage with Docker and Docker-Compose.
3 years ago
0xJacky 3ee8ef0523
feat: add setting for test nginx config command #191 3 years ago
Jacky ba4aeb85ca
fix: change language cause unexpected redirect #189 3 years ago
0xJacky 4ec19c9cda
chore: bump version to v2.0.0-beta.4 3 years ago
0xJacky 13c24ede28
temp: disable operation sync before refactoring 3 years ago
dependabot[bot] 3843fe9cef
chore(deps): bump axios from 1.5.1 to 1.6.0 in /frontend (#184)
Bumps [axios](https://github.com/axios/axios) from 1.5.1 to 1.6.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.5.1...v1.6.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
0xJacky 82eabbf17e
chore: update deprecated TLS directives #183
close #183
3 years ago
0xJacky 8ac5fc2052
feat: added gpt-4-1106-preview in ChatGPT model settings 3 years ago
dependabot[bot] 9f19d15da9
chore(deps): bump postcss from 8.4.23 to 8.4.31 in /docs (#172)
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.23 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.23...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
dependabot[bot] 32c89ac8b6
chore(deps): bump golang.org/x/net from 0.14.0 to 0.17.0 (#173)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.14.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.14.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
dependabot[bot] ff442a9a15
chore(deps): bump google.golang.org/grpc from 1.57.0 to 1.57.1 (#178)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.57.0 to 1.57.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.57.0...v1.57.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
0xJacky 2982782721
chore: rm not used debug log 3 years ago
0xJacky 5fcad2311b
fix: terminal process not killed #181 3 years ago
Hintay 4b75aed9f6 temp: disable operation synchronization before refactoring due to panic 3 years ago
Kcho ee79a2f309 Translated using Weblate (Spanish)
Currently translated at 100.0% (310 of 310 strings)

Co-authored-by: Kcho <kcholoren@gmail.com>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/es/
Translation: Nginx UI/Frontend
3 years ago
Weblate f08b60656f Update translation files
Updated by "Update LINGUAS file" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.nginxui.com/projects/nginx-ui/frontend/
Translation: Nginx UI/Frontend
3 years ago
dependabot[bot] 33e5c4b2f6
chore(deps): bump vite from 4.3.8 to 4.4.9 in /docs (#159)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.3.8 to 4.4.9.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v4.4.9/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
dependabot[bot] 5eda4abe45
chore(deps): bump semver from 5.7.1 to 5.7.2 in /docs (#158)
Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
superlollipop 2cba64c989
feat: added http host config (#157)
Co-authored-by: 0xJacky <me@jackyu.cn>
3 years ago
0xJacky 5165554282
fix: build error 3 years ago
0xJacky 5cf11813e9
refactor: translation module #135 3 years ago
0xJacky 8cc71942c8
refactor(wip): translation module #135 3 years ago
superlollipop 6ede443bbe
针对nginx+keeplived的vip映射管理方案 (#154)
* fixed environment indicator display overlay & edit not obtain newest data

* finished environment operation sync

* fix: environment indicator display overflow not ellipsis

---------

Co-authored-by: 0xJacky <me@jackyu.cn>
3 years ago
0xJacky 477bec07d8
fix: settings were not saved to file 3 years ago
0xJacky 21a6acb95b
enhance: error handling 3 years ago
0xJacky 4e14d26b3f
chore: change Token to NodeSecret #152 3 years ago
0xJacky 61ce1938b4
fix: env indicator background in dark mode 3 years ago
superlollipop 56540330f6
fix: environment indicator display overlay & edit not obtain newest data (#152)
Co-authored-by: 0xJacky <me@jackyu.cn>
3 years ago
Peter Dave Hello b257edde86
Improve zh_TW locale (#148) 3 years ago
0xJacky de9bcff99b
fix: build error 3 years ago
0xJacky 4dadecc98a
chore: update version 3 years ago
0xJacky 01611ef622
feat: added custom nginx reload/restart cmd #140 3 years ago
0xJacky cc6a325ddd
fix: analytic not send data 3 years ago
0xJacky 2bc14bd23b
enhance: ignore ws expected error 3 years ago
0xJacky 0c1b5f12c6
chore: update version 3 years ago
Kcho 1a2aabf5df
chore: added README-es.md (#128)
* fix typo

* Spanish README added.

* Update README-es.md
4 years ago
Jacky b057d92ff0
chore(ci): disabled docker build in pull request 4 years ago
Jacky 6b98c4a0c8
Merge pull request #127 from kcholoren/dev
Updates in Spanish translation and fixs
4 years ago
Kcho a2fba39b13 Fix error
Fix a newline introduced by text editor.
4 years ago
Kcho 9dcb867d60 Update Spanish translation. 4 years ago
Kcho b8177e8151 Update Russian translation.
There where a couple of errors.
4 years ago
Kcho 1226259b79 Update RightSettings.vue
Add translation to Deploy header. Please verify.
4 years ago
0xJacky e1119f0e62
Merge branch 'dev' of https://github.com/0xJacky/nginx-ui into dev 4 years ago
0xJacky 6fefa97ecc
chore: update version 4 years ago
Jacky 3403ab3e52
chore: update russian translations
Patch 2
4 years ago
Jacky cb5196b11c
chore(ci): update documents.yml
Disabled deploy to server in pull_request
4 years ago
0xJacky 4b1c1b059b
chore(ci): added markdown type to trigger 4 years ago
0xJacky fe99d83456
chore(docs): update update install shell url 4 years ago
0xJacky 5746d5db2e
style(docs): update brand-dimm color 4 years ago
0xJacky a299c0b82c
feat: use jsoniter for improving gin performance 4 years ago
0xJacky ccf548e7b7
enhance: added info to config editor 4 years ago
0xJacky 95093e8bf9
feat: added node_secret to basic settings 4 years ago
Jacky 0d1836b4f0
chore: update russian translations
Update app.po
4 years ago
iAHTOH 9f2a169fff
Update app.po
small edit style
4 years ago
iAHTOH 5b44a72082
Update app.po
stylistic changes
4 years ago
0xJacky aa6acbd18c
feat: added russian translations 4 years ago
Jacky fbc44dc794
Merge pull request #123 from iAHTOH/dev
Add russian locale files
4 years ago
iAHTOH 8ab5b89ac2 Add russian locale files 4 years ago
Jacky 304ffc36fd
Merge pull request #122 from kcholoren/dev
Spanish translation updated
4 years ago
Kcho 6ba6e63138 Spanish translation updated
New texts added in new version.
4 years ago
iAHTOH 8da49272b3 Craete folder 4 years ago
0xJacky 6ce6d43916
chore: update vitepress to v1.0.0-beta.1 4 years ago
0xJacky 1a78cebd50
chore: bump version to 2.0beta1 4 years ago
0xJacky 509d059ceb
fix: abort only when log level higher than warn 4 years ago
0xJacky e38380aac0
docs: update nginx proxy example 4 years ago
0xJacky d9f78318f1
fix(dcos): margin-left of the top logo 4 years ago
0xJacky e793d9d882
fix(docs): img path issue 4 years ago
0xJacky d3184ff8d0
docs: added docs of the syntax of config template 4 years ago
0xJacky b1b6e8fec8
chore: dry run core upgrade in demo 4 years ago
0xJacky 0265e44c17
enhance: auto restart nodeAnalyticRecord 4 years ago
0xJacky 3ae494ae9d
feat: added Spanish translation 4 years ago
0xJacky 8f683eb632
chore: update demo node 4 years ago
0xJacky 1e827fcdd7
chore: update demo 4 years ago
0xJacky ce8c1b1268
chore: clean up code 4 years ago
0xJacky 808ca3d508
fix: build error 4 years ago
0xJacky ca3d19a5d7
enhance: node analytic init 4 years ago
0xJacky 21cd91b163
fix: build error 4 years ago
0xJacky 228a36b079
enhance: record node analytic 4 years ago
0xJacky aee3b87076
chore: update .gitignore 4 years ago
0xJacky 969781f720
fix: build error 4 years ago
0xJacky 1f4e732d14
chore: rm vue-gettext 4 years ago
0xJacky 2635d0134c
feat(wip): add node system monitor in dashboard 4 years ago
0xJacky 57e1d066c0
chore: delete package-lock.json 4 years ago
Jacky f73e733a2c
Merge pull request #118 from kcholoren/dev
Spanish translation added
4 years ago
Kcho d44148cd64 Spanish translation added 4 years ago
0xJacky aa1258e0a5
chore: update zh_CN translations 4 years ago
0xJacky 4135146b67
feat: deploy site config to remote server 4 years ago
0xJacky 0bae0e0912
enhance: recovery print call stack 4 years ago
0xJacky db1b34fef1
fix: node selector badge 4 years ago
0xJacky 5021e6f4ab
style: update css 4 years ago
0xJacky 8e88d6a4b3
feat: added status badge to node selector 4 years ago
0xJacky 5e7bc3112d
style: added border-radius to ace and terminal 4 years ago
0xJacky d158857361
fix: fail to save locations #116 4 years ago
0xJacky 8c5ee48719
fix: fail to save locations #116 4 years ago
0xJacky 6c38b11ab3
feat: duplicate site config to remote #70 4 years ago
0xJacky bc6a25cd1f
fix: empty value update issue in settings 4 years ago
0xJacky cbc443eb64
chore: update zh_CN translation 4 years ago
Jacky 8a498adcb2
Merge pull request #115 from skrilax91/feature/fr-traduction
feat: Adding French translation
4 years ago
0xJacky fe4f33dd19
fix: build error 4 years ago
Léo Brossard 3d9748b17f feat: compiled french translation 4 years ago
0xJacky 47ea62adb2
feat(wip): node management #70 4 years ago
Léo Brossard a7f583bdca feat: adding fr in language selector 4 years ago
Léo Brossard 8857165f9c fix: fr_FR code not in LINGUAS file 4 years ago
Léo Brossard c49c987dc6 feat: finished all translation 4 years ago
Léo Brossard d4762f66a5 feat: adding last know translations 4 years ago
Léo Brossard 9f9c60ff71 feat: adding base traduction 4 years ago
0xJacky 3ed9ff1a19
fix: upgrade gonginx to fix the issue #73 4 years ago
0xJacky 26524d20fb
chore: move logger into internal 4 years ago
0xJacky 90af155e1b
fix(docs): start url of docker 4 years ago
Hintay 18ed5deaee
feat: add Traditional Chinese documentations 4 years ago
Hintay 7deaef920d
refactor: more user-friendly documents 4 years ago
0xJacky cab5ff2c78
feat: get lego's logs and send them to frontend 4 years ago
0xJacky 2529ca90ca
chore: update gen files 4 years ago
0xJacky af12612343
enhance: log level 4 years ago
Hintay 59ca8d9eb8
fix: logo for documents 4 years ago
0xJacky 6bc6ceac19
enhance: added error prompt in form 4 years ago
0xJacky f305701b30
refactor: use zap as logger ⚡ 4 years ago
Hintay 2831208de3
feat: show git commit reference in documents footer 4 years ago
Hintay efda5a84dc
chore: add Illustrator format logo 4 years ago
Hintay c35433f235
chore: add build and deploy action for documents 4 years ago
Hintay 20ad17bbfa
refactor: move documents image to assets folder 4 years ago
0xJacky 9ac5708eca
enhance: core upgrader 4 years ago
Hintay a2fe98e1a2
refactor: styles and i18n for documents site 4 years ago
0xJacky 5b34f0f052
chore: update digest format 4 years ago
0xJacky c16ea53ed1
feat: add digest for actions 4 years ago
0xJacky fd342e6075
chore: update logo background 4 years ago
0xJacky 9eab625ee5
style(header): use sticky replace fixed 4 years ago
0xJacky 716858ebdc
chore: rm dev environment files 4 years ago
0xJacky 0982878211
chore: update .gitignore 4 years ago
0xJacky 82704733a4
refactor: docs files struct 4 years ago
0xJacky 1ee5700aa0
feat: add ca_dir settings in webui 4 years ago
0xJacky b8b17d8cc9
fix: auto cert no resolver 4 years ago
0xJacky 47572984ea
chore: move analytic to internal 4 years ago
Hintay ee1f67b3cd
refactor: project structure 4 years ago

@ -7,15 +7,15 @@ tmp_dir = "tmp"
[build]
# Just plain old shell command. You could use `make` as well.
cmd = "CGO_ENABLED=1 go build -ldflags=\"-X 'github.com/0xJacky/Nginx-UI/server/settings.buildTime=$(date +%s)'\" -o ./tmp/main ."
cmd = "CGO_ENABLED=1 go build -tags=jsoniter -ldflags=\"-X 'github.com/0xJacky/Nginx-UI/settings.buildTime=$(date +%s)'\" -v -o ./tmp/main ."
# Binary file yields from `cmd`.
bin = "tmp/main"
# Customize binary.
full_bin = "APP_ENV=dev APP_USER=air ./tmp/main"
# Watch these filename extensions.
include_ext = ["go", "tpl", "tmpl", "html", "conf", "ini", "toml"]
include_ext = ["go", "tpl", "tmpl", "html", "toml", "po"]
# Ignore these filename extensions or directories.
exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules", "upload"]
exclude_dir = ["assets", "tmp", "vendor", "app/node_modules", "upload", "docs", "resources", ".idea"]
# Watch these directories if you specified.
include_dir = []
# Exclude files.
@ -51,3 +51,6 @@ runner = "green"
[misc]
# Delete tmp directory on exit
clean_on_exit = true
[screen]
keep_scroll = true

@ -0,0 +1,4 @@
.git
app/node_modules
.idea
tmp

@ -1,15 +1,16 @@
root = true
[*]
block_comment_start = /*
block_comment_end = */
charset = utf-8
indent_style = space
indent_size = 4
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.go]
indent_size = 4
[README.md]
indent_style = space
indent_size = 4

@ -0,0 +1,18 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "npm"
directory: "/app"
target-branch: "dev"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/"
target-branch: "dev"
schedule:
interval: "weekly"

@ -1,255 +1,266 @@
name: Build
on:
push:
branches:
- '*'
paths:
- "**/*.js"
- "**/*.vue"
- "frontend/package.json"
- "frontend/.env*"
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"
- "resources/*"
pull_request:
types: [ opened, synchronize, reopened ]
paths:
- "**/*.js"
- "**/*.vue"
- "frontend/package.json"
- "frontend/.env*"
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"
release:
types:
- published
push:
branches:
- '*'
- '!weblate'
paths:
- "app/**/*.js"
- "app/**/*.vue"
- "app/src/language/**/*.po"
- "app/i18n.json"
- "app/package.json"
- "app/.env*"
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/build*.yml"
- "resources/docker/docker/*"
- "resources/development/*"
- "resources/demo/*"
- "Dockerfile"
- "demo.Dockerfile"
pull_request:
types: [ opened, synchronize, reopened ]
paths:
- "**/*.js"
- "**/*.vue"
- "app/package.json"
- "app/.env*"
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"
- "resources/docker/docker/*"
- "resources/development/*"
- "resources/demo/*"
release:
types:
- published
jobs:
build_frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up nodejs
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'yarn'
cache-dependency-path: 'frontend/yarn.lock'
- name: Install dependencies
run: yarn install
working-directory: frontend
- name: Update translations
run: yarn gettext:compile
working-directory: frontend
- name: Build
run: |
npx browserslist@latest --update-db
yarn build
working-directory: frontend
- name: Archive frontend artifacts
uses: actions/upload-artifact@v3
with:
name: frontend-dist
path: frontend/dist
- name: Prepare publish
if: github.event_name == 'release'
run: |
cp README*.md frontend/dist
find frontend/dist -printf '%P\n' | tar -C frontend/dist --no-recursion -zcvf frontend-dist.tar.gz -T -
- name: Publish
uses: softprops/action-gh-release@v1
if: github.event_name == 'release'
with:
files: frontend-dist.tar.gz
build:
runs-on: ubuntu-latest
needs: build_frontend
strategy:
matrix:
goos: [ linux, darwin ]
goarch: [ amd64, 386, arm64 ]
exclude:
# Exclude i386 on darwin.
- goarch: 386
goos: darwin
include:
# BEGIN Linux ARM 5 6 7
- goos: linux
goarch: arm
goarm: 7
- goos: linux
goarch: arm
goarm: 6
- goos: linux
goarch: arm
goarm: 5
# END Linux ARM 5 6 7
env:
CGO_ENABLED: 1
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ^1.20.1
- name: Set up cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}-go-
- name: Setup compiler environment
id: info
run: |
export _NAME=nginx-ui-$(jq ".$GOOS[\"$GOARCH$GOARM\"].name" -r < .github/build/build_info.json)
export _ARCH=$(jq ".$GOOS[\"$GOARCH$GOARM\"].arch" -r < .github/build/build_info.json)
export _ABI=$(jq ".$GOOS[\"$GOARCH$GOARM\"].abi // \"\"" -r < .github/build/build_info.json)
export _ARTIFACT=nginx-ui-$GOOS-$GOARCH$(if [[ "$GOARM" ]]; then echo "v$GOARM"; fi)
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, ABI: $_ABI, RELEASE_NAME: $_NAME, ARTIFACT_NAME: $_ARTIFACT"
echo "ARCH_NAME=$_ARCH" >> $GITHUB_ENV
echo "ABI=$_ABI" >> $GITHUB_ENV
echo "DIST=$_NAME" >> $GITHUB_ENV
echo "ARTIFACT=$_ARTIFACT" >> $GITHUB_ENV
- name: Install musl cross compiler
if: env.GOOS == 'linux'
uses: 0xJacky/musl-cross-compilers@v0.6.5
id: musl
with:
target: ${{ env.ARCH_NAME }}-linux-musl${{ env.ABI }}
- name: Post install musl cross compiler
if: env.GOOS == 'linux'
run: |
echo "PATH=${{ steps.musl.outputs.path }}:$PATH" >> $GITHUB_ENV
echo "CC=${{ env.ARCH_NAME }}-linux-musl${{ env.ABI }}-gcc" >> $GITHUB_ENV
echo "CXX=${{ env.ARCH_NAME }}-linux-musl${{ env.ABI }}-g++" >> $GITHUB_ENV
echo "LD_FLAGS=--extldflags '-static'" >> $GITHUB_ENV
- name: Install darwin cross compiler
if: env.GOOS == 'darwin'
run: |
curl -L https://github.com/Hintay/crossosx/releases/latest/download/crossosx.tar.zst -o crossosx.tar.zst
tar xvaf crossosx.tar.zst
echo "LD_LIBRARY_PATH=$(pwd)/crossosx/lib/" >> $GITHUB_ENV
echo "PATH=$(pwd)/crossosx/bin/:$PATH" >> $GITHUB_ENV
echo "CC=${{ env.ARCH_NAME }}-clang" >> $GITHUB_ENV
echo "CXX=${{ env.ARCH_NAME }}-clang++" >> $GITHUB_ENV
echo "LD_FLAGS=-s -w" >> $GITHUB_ENV
- name: Download frontend artifacts
uses: actions/download-artifact@v3
with:
name: frontend-dist
path: frontend/dist
- name: Build
run: |
mkdir -p dist
go build -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/server/settings.buildTime=$(date +%s)'" -o dist/nginx-ui -v main.go
- name: Archive backend artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT }}
path: dist/nginx-ui
- name: Prepare publish
if: github.event_name == 'release'
run: |
cp README*.md ./dist
find dist -printf '%P\n' | tar -C dist --no-recursion -zcvf ${{ env.DIST }}.tar.gz -T -
- name: Publish
uses: softprops/action-gh-release@v1
if: github.event_name == 'release'
with:
files: ${{ env.DIST }}.tar.gz
docker-build:
runs-on: ubuntu-latest
needs: build
env:
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/arm/v5
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./dist
- name: Prepare Artifacts
run: chmod +x ./dist/nginx-ui-*/nginx-ui
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Prepare Dockerfile
if: github.event_name == 'release'
run: |
cp ./Dockerfile ./dist
cp -rp ./resources ./dist
- name: Build and push
if: github.event_name == 'release'
uses: docker/build-push-action@v3
with:
context: ./dist
file: ./dist/Dockerfile
platforms: ${{ env.PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
uozi/nginx-ui:latest
uozi/nginx-ui:${{ steps.get_version.outputs.VERSION }}
- name: Prepare Demo Dockerfile
run: |
cp ./demo.Dockerfile ./dist
cp -rp ./resources ./dist
- name: Build and push demo
uses: docker/build-push-action@v3
with:
context: ./dist
file: ./dist/demo.Dockerfile
platforms: ${{ env.PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
uozi/nginx-ui-demo:latest
build_app:
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up nodejs
uses: actions/setup-node@v4
with:
node-version: current
- name: Install dependencies
run: |
corepack enable
corepack prepare pnpm@latest --activate
pnpm install
working-directory: app
- name: Check frontend code style
run: |
pnpm run lint
working-directory: app
- name: Check frontend types
run: |
pnpm run typecheck
working-directory: app
- name: Build
run: |
npx browserslist@latest --update-db
pnpm build
working-directory: app
- name: Archive app artifacts
uses: actions/upload-artifact@v4
with:
name: app-dist
path: app/dist
- name: Prepare publish
if: github.event_name == 'release'
run: |
cp README*.md app/dist
find app/dist -printf '%P\n' | tar -C app/dist --no-recursion -zcvf app-dist.tar.gz -T -
- name: Publish
uses: softprops/action-gh-release@v2
if: github.event_name == 'release'
with:
files: app-dist.tar.gz
build:
runs-on: ubuntu-latest
needs: build_app
strategy:
matrix:
goos: [ linux, darwin ]
goarch: [ amd64, 386, arm64 ]
exclude:
# Exclude i386 on darwin.
- goarch: 386
goos: darwin
include:
# BEGIN Linux ARM 5 6 7
- goos: linux
goarch: arm
goarm: 7
- goos: linux
goarch: arm
goarm: 6
- goos: linux
goarch: arm
goarm: 5
# END Linux ARM 5 6 7
env:
CGO_ENABLED: 1
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ^1.23.0
- name: Setup compiler environment
id: info
run: |
export _NAME=nginx-ui-$(jq ".$GOOS[\"$GOARCH$GOARM\"].name" -r < .github/build/build_info.json)
export _ARCH=$(jq ".$GOOS[\"$GOARCH$GOARM\"].arch" -r < .github/build/build_info.json)
export _ABI=$(jq ".$GOOS[\"$GOARCH$GOARM\"].abi // \"\"" -r < .github/build/build_info.json)
export _ARTIFACT=nginx-ui-$GOOS-$GOARCH$(if [[ "$GOARM" ]]; then echo "v$GOARM"; fi)
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, ABI: $_ABI, RELEASE_NAME: $_NAME, ARTIFACT_NAME: $_ARTIFACT"
echo "ARCH_NAME=$_ARCH" >> $GITHUB_ENV
echo "ABI=$_ABI" >> $GITHUB_ENV
echo "DIST=$_NAME" >> $GITHUB_ENV
echo "ARTIFACT=$_ARTIFACT" >> $GITHUB_ENV
- name: Install musl cross compiler
if: env.GOOS == 'linux'
uses: 0xJacky/musl-cross-compilers@v0.6.6
id: musl
with:
target: ${{ env.ARCH_NAME }}-linux-musl${{ env.ABI }}
- name: Post install musl cross compiler
if: env.GOOS == 'linux'
run: |
echo "PATH=${{ steps.musl.outputs.path }}:$PATH" >> $GITHUB_ENV
echo "CC=${{ env.ARCH_NAME }}-linux-musl${{ env.ABI }}-gcc" >> $GITHUB_ENV
echo "CXX=${{ env.ARCH_NAME }}-linux-musl${{ env.ABI }}-g++" >> $GITHUB_ENV
echo "LD_FLAGS=-w --extldflags '-static'" >> $GITHUB_ENV
- name: Install darwin cross compiler
if: env.GOOS == 'darwin'
run: |
curl -L https://github.com/Hintay/crossosx/releases/latest/download/crossosx.tar.zst -o crossosx.tar.zst
tar xvaf crossosx.tar.zst
echo "LD_LIBRARY_PATH=$(pwd)/crossosx/lib/" >> $GITHUB_ENV
echo "PATH=$(pwd)/crossosx/bin/:$PATH" >> $GITHUB_ENV
echo "CC=${{ env.ARCH_NAME }}-clang" >> $GITHUB_ENV
echo "CXX=${{ env.ARCH_NAME }}-clang++" >> $GITHUB_ENV
echo "LD_FLAGS=-w" >> $GITHUB_ENV
- name: Download app artifacts
uses: actions/download-artifact@v4
with:
name: app-dist
path: app/dist
- name: Build
run: |
mkdir -p dist
go build -tags=jsoniter -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/settings.buildTime=$(date +%s)'" -o dist/nginx-ui -v main.go
- name: Archive backend artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT }}
path: dist/nginx-ui
- name: Prepare publish
if: github.event_name == 'release'
run: |
cp README*.md ./dist
find dist -printf '%P\n' | tar -C dist --no-recursion -zcvf ${{ env.DIST }}.tar.gz -T -
openssl dgst -sha512 ${{ env.DIST }}.tar.gz | sed 's/([^)]*)//g' | awk '{print $NF}' >> ${{ env.DIST }}.tar.gz.digest
- name: Publish
uses: softprops/action-gh-release@v2
if: github.event_name == 'release'
with:
files: |
${{ env.DIST }}.tar.gz
${{ env.DIST }}.tar.gz.digest
docker-build:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
needs: build
env:
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/arm/v5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ./dist
- name: Prepare Artifacts
run: chmod +x ./dist/nginx-ui-*/nginx-ui
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Prepare Dockerfile
if: github.event_name == 'release'
run: |
cp ./Dockerfile ./dist
cp -rp ./resources ./dist
- name: Build and push
if: github.event_name == 'release'
uses: docker/build-push-action@v5
with:
context: ./dist
file: ./dist/Dockerfile
platforms: ${{ env.PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
uozi/nginx-ui:latest
uozi/nginx-ui:${{ steps.get_version.outputs.VERSION }}
- name: Prepare Demo Dockerfile
run: |
cp ./demo.Dockerfile ./dist
cp -rp ./resources ./dist
- name: Build and push demo
uses: docker/build-push-action@v5
with:
context: ./dist
file: ./dist/demo.Dockerfile
platforms: ${{ env.PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
uozi/nginx-ui-demo:latest

@ -0,0 +1,99 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
paths-ignore:
- '**/*.md'
- '**/*.ini'
schedule:
- cron: '34 6 * * *'
jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
security-events: write
# required to fetch internal or private CodeQL packs
packages: read
# only required for workflows in private repositories
actions: read
contents: read
strategy:
fail-fast: false
matrix:
include:
- language: go
build-mode: autobuild
- language: javascript-typescript
build-mode: none
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"

@ -0,0 +1,64 @@
name: Build Documents
on:
push:
branches:
- '*'
paths:
- "docs/**/*.js"
- "docs/**/*.ts"
- "docs/**/*.vue"
- "docs/package.json"
- "docs/.env*"
- "docs/**/*.md"
- ".github/workflows/doc*.yml"
pull_request:
types: [ opened, synchronize, reopened ]
paths:
- "docs/**/*.js"
- "docs/**/*.ts"
- "docs/**/*.vue"
- "docs/package.json"
- "docs/.env*"
- "docs/**/*.md"
- ".github/workflows/doc*.yml"
jobs:
build:
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up nodejs
uses: actions/setup-node@v4
with:
node-version: 21.x
- name: Install dependencies
run: |
corepack enable
corepack prepare pnpm@latest --activate
pnpm install
working-directory: docs
- name: Build
run: COMMIT_REF=$(git rev-parse HEAD) pnpm docs:build
working-directory: docs
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: docs/.vitepress/dist
- name: Deploy to server
if: github.event_name != 'pull_request'
uses: easingthemes/ssh-deploy@main
env:
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
TARGET: ${{ secrets.REMOTE_TARGET }}
SOURCE: "docs/.vitepress/dist/"
ARGS: "-rlgoDzvc -i --delete"

@ -0,0 +1,32 @@
name: Weblate Pull Branch
on:
workflow_dispatch:
pull_request_target:
branches:
- 'dev'
types: [ closed ]
release:
types:
- published
jobs:
weblate:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true || github.event.action == 'published' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install wlc
run: pip install wlc
- name: Update Repository
env:
WEBLATE_TOKEN: ${{ secrets.WEBLATE_TOKEN }}
run: wlc --key $WEBLATE_TOKEN pull

@ -0,0 +1,86 @@
name: Synchronize Weblate Branch
on:
workflow_dispatch:
schedule:
- cron: '15 18 * * *'
env:
DEVELOP_BRANCH: dev
WEBLATE_BRANCH: weblate
jobs:
check:
name: Check Branches
runs-on: ubuntu-latest
outputs:
behind: ${{ steps.check.outputs.behind }}
ahead: ${{ steps.check.outputs.ahead }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.DEVELOP_BRANCH }}
clean: false
fetch-depth: 0
- name: Check branches
id: check
run: |
git fetch --all
git branch $WEBLATE_BRANCH origin/$WEBLATE_BRANCH
echo "behind=$(git rev-list --count $WEBLATE_BRANCH..$DEVELOP_BRANCH)" >> $GITHUB_OUTPUT
echo "ahead=$(git rev-list --count $DEVELOP_BRANCH..$WEBLATE_BRANCH)" >> $GITHUB_OUTPUT
- name: Echo outputs
run: |
echo "behind: ${{ steps.check.outputs.behind }}"
echo "ahead: ${{ steps.check.outputs.ahead }}"
force-update:
name: Force Update Weblate Status
runs-on: ubuntu-latest
needs: check
if: ${{ needs.check.outputs.behind > 0 }}
env:
WEBLATE_TOKEN: ${{ secrets.WEBLATE_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install wlc
run: pip install wlc
- name: Update weblate repository
run: wlc --key $WEBLATE_TOKEN pull
- name: Push weblate branch
run: wlc --key $WEBLATE_TOKEN push
sync-branch:
name: Sync Weblate Branch
runs-on: ubuntu-latest
needs: [check, force-update]
if: ${{ needs.check.outputs.ahead > 0 && always() }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.DEVELOP_BRANCH }}
fetch-depth: 0
- name: Set up git
run: |
git config --global user.name 'Weblate'
git config --global user.email 'weblate@nginxui.com'
- name: Push changes of weblate branch to develop branch
run: |
git fetch origin
git merge --ff-only -- origin/${{ env.WEBLATE_BRANCH }}
git push origin ${{ env.DEVELOP_BRANCH }}

7
.gitignore vendored

@ -1,10 +1,13 @@
.DS_Store
.idea
database.db
tmp
node_modules
/app.ini
.pnpm-store
app.ini
dist
*.exe
*.po~
nginx-ui
resources/development/nginx
app/.env
app/.status_hash

10
.idea/.gitignore vendored

@ -0,0 +1,10 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# GitHub Copilot persisted chat sessions
/copilot/chatSessions

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/nginx-ui.iml" filepath="$PROJECT_DIR$/.idea/nginx-ui.iml" />
</modules>
</component>
</project>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -0,0 +1,3 @@
[weblate]
url = https://weblate.nginxui.com/api/
translation = nginx-ui

@ -2,17 +2,28 @@ FROM --platform=$TARGETPLATFORM uozi/nginx-ui-base:latest
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
WORKDIR /app
EXPOSE 80 443
COPY resources/docker/start.sh /app/start.sh
COPY resources/docker/nginx.conf /usr/etc/nginx/nginx.conf
COPY resources/docker/nginx-ui.conf /usr/etc/nginx/conf.d/nginx-ui.conf
COPY resources/docker/nginx-ui.conf /etc/nginx/conf.d/nginx-ui.conf
COPY nginx-ui-$TARGETOS-$TARGETARCH$TARGETVARIANT/nginx-ui /app/nginx-ui
ENV NGINX_UI_OFFICIAL_DOCKER=true
RUN cd /app && chmod a+x /app/start.sh \
&& rm -f /etc/nginx/conf.d/default.conf \
&& rm -f /usr/etc/nginx/conf.d/default.conf
# register nginx-ui service
COPY resources/docker/nginx-ui.run /etc/s6-overlay/s6-rc.d/nginx-ui/run
RUN echo 'longrun' > /etc/s6-overlay/s6-rc.d/nginx-ui/type && \
touch /etc/s6-overlay/s6-rc.d/user/contents.d/nginx-ui
ENTRYPOINT ["./start.sh"]
# copy nginx config
COPY resources/docker/nginx.conf /usr/local/etc/nginx/nginx.conf
COPY resources/docker/nginx-ui.conf /usr/local/etc/nginx/conf.d/nginx-ui.conf
# copy nginx-ui executable binary
COPY nginx-ui-$TARGETOS-$TARGETARCH$TARGETVARIANT/nginx-ui /usr/local/bin/nginx-ui
# remove default nginx config
RUN rm -f /etc/nginx/conf.d/default.conf \
&& rm -f /usr/local/etc/nginx/conf.d/default.conf
# recreate access.log and error.log
RUN rm -f /var/log/nginx/access.log && \
touch /var/log/nginx/access.log && \
rm -f /var/log/nginx/error.log && \
touch /var/log/nginx/error.log

@ -0,0 +1,319 @@
<div align="center">
<img src="resources/logo.png" alt="Logotipo de la interfaz de usuario de Nginx">
</div>
# Interfaz de usuario (UI) de Nginx
Otra UI web de Nginx, desarrollada por [0xJacky](https://jackyu.cn/) y [Hintay](https://blog.kugeek.com/).
[![Build and Publish](https://github.com/0xJacky/nginx-ui/actions/workflows/build.yml/badge.svg)](https://github.com/0xJacky/nginx-ui/actions/workflows/build.yml)
## Documentación
Para consultar la documentación, visite [nginxui.com](https://nginxui.com).
## Stargazers en el tiempo
[![Stargazers over time](https://starchart.cc/0xJacky/nginx-ui.svg)](https://starchart.cc/0xJacky/nginx-ui)
[English](README.md) | Español | [简体中文](README-zh_CN.md) | [繁體中文](README-zh_TW.md)
<details>
<summary>Tabla de Contenidos</summary>
<ol>
<li>
<a href="#about-the-project">Sobre el proyecto</a>
<ul>
<li><a href="#demo">Demostración</a></li>
<li><a href="#features">Características</a></li>
<li><a href="#internationalization">Internacionalización</a></li>
<li><a href="#built-with">Desarrollado con</a></li>
</ul>
</li>
<li>
<a href="#getting-started">Cómo empezar</a>
<ul>
<li><a href="#before-use">Antes de usar</a></li>
<li><a href="#installation">Instalación</a></li>
<li>
<a href="#usage">Uso</a>
<ul>
<li><a href="#from-executable">Desde el ejecutable</a></li>
<li><a href="#with-systemd">Con Systemd</a></li>
<li><a href="#with-docker">Con Docker</a></li>
</ul>
</li>
</ul>
</li>
<li>
<a href="#manual-build">Compilación manual</a>
<ul>
<li><a href="#prerequisites">Prerequisitos</a></li>
<li><a href="#build-app">Compilación del Frontend</a></li>
<li><a href="#build-backend">Compilación del Backend</a></li>
</ul>
</li>
<li>
<a href="#script-for-linux">Script para Linux</a>
<ul>
<li><a href="#basic-usage">Uso Básico</a></li>
<li><a href="#more-usage">Uso Avanzado</a></li>
</ul>
</li>
<li><a href="#example-of-nginx-reverse-proxy-configuration">Ejemplo de configuración de proxy reverso de Nginx</a></li>
<li><a href="#contributing">Contribuir</a></li>
<li><a href="#license">Licencia</a></li>
</ol>
</details>
## Sobre el proyecto
![Dashboard](resources/screenshots/dashboard_es.png)
### Demostración
URL:[https://demo.nginxui.com](https://demo.nginxui.com)
- Nombre de usuario: admin
- Contraseña: admin
### Características
- Estadísticas en línea para los indicadores del servidor, como el uso de la CPU, el uso de la memoria, el promedio de carga y el uso del disco.
- Asistente de ChatGPT en línea
- Despliegue con un solo clic y renovación automática de certificados Let's Encrypt.
- Edición de las configuraciones de sitios web con nuestro **NgxConfigEditor** de diseño propio, que es un editor de bloques fácil de usar para configuraciones de nginx o con el **Editor de código Ace** que admite resaltar la sintaxis de configuración de nginx.
- Visualización en línea los registros de Nginx
- Escrito en Go y Vue, distribuído en un único binario ejecutable.
- Prueba automática del archivo de configuración y recarga de nginx después de guardar la configuración.
- Terminal Web
- Modo oscuro
- Diseño web adaptable
### Internacionalización
- Inglés
- Chino Simplificado
- Chino Tradicional
Aceptamos traducciones a cualquier idioma.
### Desarrollado con
- [El lenguaje de programación Go](https://go.dev)
- [Gin Web Framework](https://gin-gonic.com)
- [GORM](http://gorm.io)
- [Vue 3](https://v3.vuejs.org)
- [Vite](https://vitejs.dev)
- [TypeScript](https://www.typescriptlang.org/)
- [Ant Design Vue](https://antdv.com)
- [vue3-gettext](https://github.com/jshmrtn/vue3-gettext)
- [vue3-ace-editor](https://github.com/CarterLi/vue3-ace-editor)
- [Gonginx](https://github.com/tufanbarisyildirim/gonginx)
## Cómo empezar
### Antes de usar
La UI de Nginx sigue la configuración estándar de archivos de un servidor web de Debian. Los archivos de configuración del sitio creados se colocarán en la carpeta `sites-available` que se encuentra dentro de la carpeta de configuración de Nginx (detectada automáticamente). Los archivos de configuración para un sitio habilitado crearán un soft link en la carpeta `sites-enabled`. Es posible que deba ajustar la forma en que se organizan los archivos de configuración.
Para sistemas que no sean Debian (y Ubuntu), es posible que deba cambiar el contenido del archivo de configuración `nginx.conf` al estilo Debian como se muestra a continuación.
```nginx
http {
# ...
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
```
Para más información: [debian/conf/nginx.conf](https://salsa.debian.org/nginx-team/nginx/-/blob/master/debian/conf/nginx.conf#L59-L60)
### Instalación
La UI de Nginx está disponible en las siguientes plataformas:
- macOS 11 Big Sur y posterior (amd64 / arm64)
- Linux 2.6.23 and later (x86 / amd64 / arm64 / armv5 / armv6 / armv7)
- Incluyendo pero no limitado a Debian 7 / 8, Ubuntu 12.04 / 14.04 and later, CentOS 6 / 7, Arch Linux
- FreeBSD
- OpenBSD
- Dragonfly BSD
- Openwrt
Puede visitar [latest release](https://github.com/0xJacky/nginx-ui/releases/latest) para descargar la última distribución, o simplemente usar los [scripts de instalación para Linux](#script-for-linux).
### Uso
Al ejecutar por primera vez la UI de Nginx, visite en su navegador `http://<your_server_ip>:<listen_port>` para completar las configuraciones posteriores.
#### Desde el ejecutable
**Ejecutar UI Nginx en la terminal**
```shell
nginx-ui -config app.ini
```
Presione `Control+C` en la terminal para salir de la UI de Nginx.
**Ejecutar UI Nginx en Segundo plano**
```shell
nohup ./nginx-ui -config app.ini &
```
Detenga la UI de Nginx con el siguiente comando.
```shell
kill -9 $(ps -aux | grep nginx-ui | grep -v grep | awk '{print $2}')
```
#### Con Systemd
Si está utilizando el [script de instalación para Linux](#script-for-linux), la UI de Nginx se instalará como el servicio `nginx-ui` en systemd. Utilice el comando `systemctl` para controlarlo.
**Iniciar UI Nginx**
```shell
systemctl start nginx-ui
```
**Detener UI Nginx**
```shell
systemctl stop nginx-ui
```
**Reiniciar UI Nginx**
```shell
systemctl restart nginx-ui
```
#### Con Docker
Nuestra imagen dpcker [uozi/nginx-ui:latest](https://hub.docker.com/r/uozi/nginx-ui) se basa en la última imagen nginx y se puede usar para reemplazar Nginx en el host. Puede realizar el cambio fácilmente publicando los puertos 80 y 443 del contenedor en el host.
##### Nota
1. Cuando utilice este contenedor por primera vez, asegúrese de que el volumen mapeado a /etc/nginx esté vacío.
2. Si desea incluir archivos estáticos, puede mapear directorios al contenedor.
**Ejemplo de desplegado Docker**
```bash
docker run -dit \
--name=nginx-ui \
--restart=always \
-e TZ=Asia/Shanghai \
-v /mnt/user/appdata/nginx:/etc/nginx \
-v /mnt/user/appdata/nginx-ui:/etc/nginx-ui \
-v /var/www:/var/www \
-p 8080:80 -p 8443:443 \
uozi/nginx-ui:latest
```
## Compilación manual
En plataformas que no tienen una versión de compilación oficial, pueden compilarse manualmente.
### Prerequisitos
- Make
- Golang 1.23+
- node.js 21+
```shell
npx browserslist@latest --update-db
```
### Compilación del Frontend
Ejecute el siguiente comando en el directorio `app`.
```shell
pnpm install
pnpm build
```
### Compilación del Backend
Primero compile la interfaz y luego ejecute el siguiente comando en el directorio raíz del proyecto.
```shell
go build -tags=jsoniter -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/settings.buildTime=$(date +%s)'" -o nginx-ui -v main.go
```
## Script para Linux
### Uso básico
**Instalar and Actualizar**
```shell
bash <(curl -L -s https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) install
```
El puerto de escucha predeterminado es `9000` y el puerto de Desafío HTTP predeterminado es `9180`.
Si hay un conflicto de puertos, modifique manualmente `/usr/local/etc/nginx-ui/app.ini`,
luego use `systemctl restart nginx-ui` para recargar el servicio de UI de Nginx.
**Eliminar UI Nginx UI, excepto los archivos de configuración y la base de datos**
```shell
bash <(curl -L -s https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) remove
```
### Uso avanzado
````shell
bash <(curl -L -s https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) help
````
## Ejemplo de configuración de proxy reverso de Nginx
```nginx
server {
listen 80;
listen [::]:80;
server_name <your_server_name>;
rewrite ^(.*)$ https://$host$1 permanent;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name <your_server_name>;
ssl_certificate /path/to/ssl_cert;
ssl_certificate_key /path/to/ssl_cert_key;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://127.0.0.1:9000/;
}
}
```
## Contribuir
Las contribuciones son lo que hace que la comunidad de código abierto sea un lugar increíble para aprender, inspirar y crear. Cualquier contribución que hagas es **muy apreciada**.
Si tiene una sugerencia que mejoraría este proyecto, bifurque el repositorio y cree un pull request. También puede simplemente abrir un issue con la etiqueta "enhancement". ¡No olvides darle una estrella al proyecto! ¡Gracias de nuevo!
1. Bifurcar el proyecto
2. Crea un branch de mejora (`git checkout -b feature/AmazingFeature`)
3. Commit de tus cambios (`git commit -m 'Add some AmazingFeature'`)
4. Push al branch (`git push origin feature/AmazingFeature`)
5. Abrir un Pull Request
## Licencia
Este proyecto se proporciona bajo una licencia GNU Affero General Public License v3.0 que se puede encontrar en el archivo [LICENCIA](LICENSE). Al usar, distribuir o contribuir a este proyecto, acepta los términos y condiciones de esta licencia.

@ -0,0 +1,388 @@
<div align="center">
<img src="resources/logo.png" alt="Nginx UI Logo">
</div>
# Nginx UI
Yet another Nginx Web UI, được phát triển bởi [0xJacky](https://jackyu.cn/) và [Hintay](https://blog.kugeek.com/).
[![Build and Publish](https://github.com/0xJacky/nginx-ui/actions/workflows/build.yml/badge.svg)](https://github.com/0xJacky/nginx-ui/actions/workflows/build.yml)
[![GitHub license](https://img.shields.io/github/license/0xJacky/nginx-ui?label=License&logo=github)](https://github.com/0xJacky/nginx-ui "Click to view the repo on Github")
[![Release Version](https://img.shields.io/github/release/0xJacky/nginx-ui?include_prereleases&label=Release&logo=github)](https://github.com/0xJacky/nginx-ui/releases/latest "Click to view the repo on Github")
[![GitHub Star](https://img.shields.io/github/stars/0xJacky/nginx-ui?label=Stars&logo=github)](https://github.com/0xJacky/nginx-ui "Click to view the repo on Github")
[![GitHub Fork](https://img.shields.io/github/forks/0xJacky/nginx-ui?label=Forks&logo=github)](https://github.com/0xJacky/nginx-ui "Click to view the repo on Github")
[![Repo Size](https://img.shields.io/github/repo-size/0xJacky/nginx-ui?label=Size&logo=github)](https://github.com/0xJacky/nginx-ui "Click to view the repo on Github")
[![GitHub Fork](https://img.shields.io/github/issues-closed-raw/0xJacky/nginx-ui?label=Closed%20Issue&logo=github)](https://github.com/0xJacky/nginx-ui/issue "Click to view the repo on Github")
[![Docker Stars](https://img.shields.io/docker/stars/uozi/nginx-ui?label=Stars&logo=docker)](https://hub.docker.com/r/uozi/nginx-ui "Click to view the image on Docker Hub")
[![Docker Pulls](https://img.shields.io/docker/pulls/uozi/nginx-ui?label=Pulls&logo=docker)](https://hub.docker.com/r/uozi/nginx-ui "Click to view the image on Docker Hub")
[![Image Size](https://img.shields.io/docker/image-size/uozi/nginx-ui/latest?label=Image%20Size&logo=docker)](https://hub.docker.com/r/uozi/nginx-ui "Click to view the image on Docker Hub")
## Tài liệu
Để xem tài liệu, hãy truy cập [nginxui.com](https://nginxui.com).
## Stargazers over time
[![Stargazers over time](https://starchart.cc/0xJacky/nginx-ui.svg)](https://starchart.cc/0xJacky/nginx-ui)
English | [Español](README-es.md) | [简体中文](README-zh_CN.md) | [繁體中文](README-zh_TW.md) | [Tiếng Việt](README-vi_VN.md)
<details>
<summary>Mục lục</summary>
<ol>
<li>
<a href="#about-the-project">Thông tin dự án</a>
<ul>
<li><a href="#demo">Demo</a></li>
<li><a href="#features">Tính năng</a></li>
<li><a href="#internationalization">Ngôn ngữ hiển thị</a></li>
<li><a href="#built-with">Được xây dựng với</a></li>
</ul>
</li>
<li>
<a href="#getting-started">Bắt đầu</a>
<ul>
<li><a href="#before-use">Lưu ý trước khi sử dụng</a></li>
<li><a href="#installation">Cài đặt</a></li>
<li>
<a href="#usage">Cách dùng</a>
<ul>
<li><a href="#from-executable">Sử dụng với Executable</a></li>
<li><a href="#with-systemd">Sử dụng với Systemd</a></li>
<li><a href="#with-docker">Sử dụng với Docker</a></li>
</ul>
</li>
</ul>
</li>
<li>
<a href="#manual-build">Build từ mã nguồn</a>
<ul>
<li><a href="#prerequisites">Điều kiện cần</a></li>
<li><a href="#build-app">Build Frontend</a></li>
<li><a href="#build-backend">Build Backend</a></li>
</ul>
</li>
<li>
<a href="#script-for-linux">Script cho Linux</a>
<ul>
<li><a href="#basic-usage">Sử dụng cơ bản</a></li>
<li><a href="#more-usage">Sử dụng nâng cao</a></li>
</ul>
</li>
<li><a href="#example-of-nginx-reverse-proxy-configuration">Ví dụ về cấu hình Nginx Reverse Proxy</a></li>
<li><a href="#contributing">Đóng góp</a></li>
<li><a href="#license">Giấy phép</a></li>
</ol>
</details>
## Về dự án
![Dashboard](resources/screenshots/dashboard_en.png)
### Demo
URL:[https://demo.nginxui.com](https://demo.nginxui.com)
- Username:admin
- Password:admin
### Tính năng
- Thống kê trực tuyến cho các chỉ số máy chủ như mức sử dụng CPU, mức sử dụng bộ nhớ, mức tải trung bình và mức sử dụng ổ đĩa.
- Chat với trợ lý ChatGPT
- Triển khai bằng một cú nhấp chuột và tự động gia hạn chứng chỉ Let's Encrypt.
- Chỉnh sửa cấu hình Nginx từ UI với **NgxConfigEditor** tự thiết kế của chúng tôi, một trình chỉnh sửa khối thân thiện với người dùng cho cấu hình nginx hoặc **Ace Code Editor** hỗ trợ làm nổi bật cú pháp cấu hình nginx.
- Xem Nginx logs
- Được viết bằng Go và Vue, và được phân phối với một tệp nhị phân thực thi duy nhất.
- Tự động kiểm tra file cấu hình và tải lại nginx sau khi lưu cấu hình.
- Web Terminal
- Dark Mode
- Responsive Web Design
### Ngôn ngữ hiển thị
- Tiếng Việt
- Tiếng Anh
- Tiếng Nga
- Tiếng Pháp
- Tiếng Tây Ban Nha
- Tiếng Trung giản thể
- Tiếng Trung phồn thể
Chúng tôi hoan nghênh bản dịch sang bất kỳ ngôn ngữ nào.
### Được xây dựng với
- [The Go Programming Language](https://go.dev)
- [Gin Web Framework](https://gin-gonic.com)
- [GORM](http://gorm.io)
- [Vue 3](https://v3.vuejs.org)
- [Vite](https://vitejs.dev)
- [TypeScript](https://www.typescriptlang.org/)
- [Ant Design Vue](https://antdv.com)
- [vue3-gettext](https://github.com/jshmrtn/vue3-gettext)
- [vue3-ace-editor](https://github.com/CarterLi/vue3-ace-editor)
- [Gonginx](https://github.com/tufanbarisyildirim/gonginx)
## Bắt đầu
### Lưu ý trước khi sử dụng
Máy chủ của bạn sẽ cần phải cài Nginx trước khi cài đặt Nginx UI
Nginx UI tuân theo tiêu chuẩn tệp cấu hình máy chủ web Debian. Các tệp cấu hình trang web đã tạo sẽ được đặt trong thư mục /etc/nginx/sites-available (được phát hiện tự động). Các tệp cấu hình cho một trang web được kích hoạt sẽ tạo một symlink đến thư mục /etc/nginx/sites-enabled. Bạn có thể cần điều chỉnh cách sắp xếp các tệp cấu hình của mình.
Đối với các hệ thống không phải Debian (và Ubuntu), bạn có thể cần thay đổi nội dung của tệp cấu hình nginx.conf thành kiểu Debian như hiển thị bên dưới.
```nginx
http {
# ...
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
```
Để biết thêm thông tin: [debian/conf/nginx.conf](https://salsa.debian.org/nginx-team/nginx/-/blob/master/debian/conf/nginx.conf#L59-L60)
### Cài đặt
Giao diện người dùng Nginx có sẵn trên các nền tảng sau:
- macOS 11 Big Sur and later (amd64 / arm64)
- Linux 2.6.23 and later (x86 / amd64 / arm64 / armv5 / armv6 / armv7)
- Bao gồm nhưng không giới hạn Debian 7/8, Ubuntu 12.04/14.04 trở lên, CentOS 6/7, Arch Linux
- FreeBSD
- OpenBSD
- Dragonfly BSD
- Openwrt
Bạn có thể truy cập [latest release](https://github.com/0xJacky/nginx-ui/releases/latest) để tải xuống bản phân phối mới nhất hoặc sử dụng [Tập lệnh cài đặt cho Linux](#script-for-linux).
### Sử dụng
Trong lần chạy đầu tiên, vui lòng truy cập `http://<your_server_ip>:<listen_port>` bằng trình duyệt của bạn để hoàn tất các cấu hình.
#### Chạy với Executable
**Chạy giao diện người dùng Nginx trong Terminal**
```shell
nginx-ui -config app.ini
```
Bấm `Ctrl + C` vào terminal để thoát Nginx UI.
**Chạy nền (Background)**
```shell
nohup ./nginx-ui -config app.ini &
```
Dừng Nginx UI bằng lệnh sau.
```shell
kill -9 $(ps -aux | grep nginx-ui | grep -v grep | awk '{print $2}')
```
#### Chạy với Systemd
Nếu bạn sử dụng [tập lệnh cài đặt cho Linux](#script-for-linux), Nginx UI sẽ được cài đặt dưới dạng `nginx-ui` service trong systemd. Hãy sử dụng `systemctl` để điều khiển nó.
**Start Nginx UI**
```shell
systemctl start nginx-ui
```
**Stop Nginx UI**
```shell
systemctl stop nginx-ui
```
**Restart Nginx UI**
```shell
systemctl restart nginx-ui
```
#### Sử dụng với Docker
Docker image của chúng tôi [uozi/nginx-ui:latest](https://hub.docker.com/r/uozi/nginx-ui) dựa trên nginx image mới nhất và có thể được sử dụng để thay thế Nginx trên máy chủ. Bằng cách xuất bản cổng 80 và 443 của container, bạn có thể dễ dàng thực hiện chuyển đổi.
##### Ghi chú
1. Khi khởi chạy container lần đầu tiên, hãy chắc chắn thư mục /etc/nginx trên máy host là rỗng.
2. Nếu bạn muốn lưu trữ các tệp tĩnh, bạn có thể mount các thư mục vào container.
<details>
<summary><b>Triển khai với Docker</b></summary>
1. [Cài đặt Docker.](https://docs.docker.com/install/)
2. Sau đó triển khai nginx-ui như thế sau:
```bash
docker run -dit \
--name=nginx-ui \
--restart=always \
-e TZ=Asia/Shanghai \
-v /mnt/user/appdata/nginx:/etc/nginx \
-v /mnt/user/appdata/nginx-ui:/etc/nginx-ui \
-p 8080:80 -p 8443:443 \
uozi/nginx-ui:latest
```
3. Khi container đã hoạt động, truy cập vào trang quản trị nginx-ui theo liên kết `http://<your_server_ip>:8080/install`.
</details>
<details>
<summary><b>Triển khai với Docker-Compose</b></summary>
1. [Cài đặt Docker-Compose.](https://docs.docker.com/compose/install/)
2. Tạo tệp docker-compose.yml:
```yml
version: '3.3'
services:
nginx-ui:
stdin_open: true
tty: true
container_name: nginx-ui
restart: always
environment:
- TZ=Asia/Shanghai
volumes:
- '/mnt/user/appdata/nginx:/etc/nginx'
- '/mnt/user/appdata/nginx-ui:/etc/nginx-ui'
- '/var/www:/var/www'
ports:
- 8080:80
- 8443:443
image: 'uozi/nginx-ui:latest'
```
3. Sau đó tạo container bằng lệnh:
```bash
docker-compose up -d
```
Nếu bạn sử dụng docker-compose-plugin, lệnh sẽ như sau
```bash
docker compose up -d
```
4. Khi container đã hoạt động, truy cập vào trang quản trị nginx-ui theo liên kết `http://<your_server_ip>:8080/install`.
</details>
## Xây dựng thủ công
Trên các nền tảng không có phiên bản xây dựng chính thức, chúng có thể được xây dựng thủ công.
### Điều kiện cần
- Make
- Golang 1.23+
- node.js 21+
```shell
npx browserslist@latest --update-db
```
### Build Frontend
Vui lòng thực hiện lệnh sau trong thư mục `app`.
```shell
pnpm install
pnpm build
```
### Build Backend
Vui lòng build Frontend trước, sau đó thực hiện lệnh sau trong thư mục gốc của dự án.
```shell
go build -tags=jsoniter -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/settings.buildTime=$(date +%s)'" -o nginx-ui -v main.go
```
## Tập lệnh cho Linux
### Cách sử dụng cơ bản
**Cài đặt và nâng cấp**
```shell
bash <(curl -L -s https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) install
```
Port mặc định để truy cập UI là `9000`, port HTTP Challenge mặc định để xác thực SSL là `9180`.
Nếu có xung đột port, vui lòng sửa đổi trong file `/usr/local/etc/nginx-ui/app.ini`,
hãy nhớ restart nginx-ui bằng lệnh `systemctl restart nginx-ui` mỗi khi bạn sửa đổi file app.ini.
**Gỡ bỏ Nginx UI nhưng giữ lại các tệp cấu hình và cơ sở dữ liệu**
```shell
bash <(curl -L -s https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) remove
```
**Gỡ bỏ Nginx UI đồng thời xoá các tệp cấu hình, cơ sở dữ liệu**
```shell
bash <(curl -L -s https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) remove --purge
```
### Trợ giúp
````shell
bash <(curl -L -s https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) help
````
## Ví dụ về cấu hình Nginx Reverse Proxy
```nginx
server {
listen 80;
listen [::]:80;
server_name <your_server_name>;
rewrite ^(.*)$ https://$host$1 permanent;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name <your_server_name>;
ssl_certificate /path/to/ssl_cert;
ssl_certificate_key /path/to/ssl_cert_key;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://127.0.0.1:9000/;
}
}
```
## Đóng góp
Đóng góp là điều khiến cộng đồng nguồn mở trở thành một nơi tuyệt vời để học hỏi, truyền cảm hứng và sáng tạo. Bất kỳ đóng góp nào bạn thực hiện đều được **đánh giá cao**.
Nếu bạn có đề xuất giúp dự án tốt hơn, vui lòng phân nhánh repo và tạo pull request. Bạn cũng có thể mở một issue mới với thẻ "enhancement" để đề xuất tính năng. Đừng quên cho dự án một Star! Cảm ơn một lần nữa!
1. Fork dự án
2. Tạo Branch (`git checkout -b feature/AmazingFeature`)
3. Commit thay đổi (`git commit -m 'Add some AmazingFeature'`)
4. Đẩy code lên Branch (`git push origin feature/AmazingFeature`)
5. Mở một Pull Request
## Giấy phép
Dự án này được cung cấp theo giấy phép GNU Affero General Public License v3.0 có thể tìm thấy trong tệp [LICENSE](LICENSE). Bằng cách sử dụng, phân phối hoặc đóng góp cho dự án này, bạn đồng ý với các điều khoản và điều kiện của giấy phép này.

@ -10,7 +10,7 @@ Nginx 网络管理界面,由 [0xJacky](https://jackyu.cn/) 与 [Hintay](https
[![Build and Publish](https://github.com/0xJacky/nginx-ui/actions/workflows/build.yml/badge.svg)](https://github.com/0xJacky/nginx-ui/actions/workflows/build.yml)
[English](README.md) | 简体中文 | [繁體中文](README-zh_TW.md)
[English](README.md) | [Español](README-es.md) | 简体中文 | [繁體中文](README-zh_TW.md)
<details>
<summary>目录</summary>
@ -125,7 +125,7 @@ http {
Nginx UI 可在以下平台中使用:
- Mac OS X 10.10 Yosemite 及之后版本(amd64 / arm64)
- macOS 11 Big Sur 及之后版本(amd64 / arm64)
- Linux 2.6.23 及之后版本(x86 / amd64 / arm64 / armv5 / armv6 / armv7)
- 包括但不限于 Debian 7 / 8、Ubuntu 12.04 / 14.04 及后续版本、CentOS 6 / 7、Arch Linux
- FreeBSD
@ -137,7 +137,7 @@ Nginx UI 可在以下平台中使用:
### 使用方法
第一次运行 Nginx UI 时,请在浏览器中访问 `http://<your_server_ip>:<listen_port>/install` 完成后续配置。
第一次运行 Nginx UI 时,请在浏览器中访问 `http://<your_server_ip>:<listen_port>` 完成后续配置。
#### 通过执行文件运行
**在终端中运行 Nginx UI**
@ -207,9 +207,9 @@ docker run -dit \
- Make
- Golang 1.19+
- Golang 1.23+
- node.js 18+
- node.js 21+
```shell
npx browserslist@latest --update-db
@ -217,12 +217,11 @@ docker run -dit \
### 构建前端
请在 `frontend` 目录中执行以下命令。
请在 `app` 目录中执行以下命令。
```shell
yarn install
make translations
yarn build
pnpm install
pnpm build
```
### 构建后端
@ -230,7 +229,7 @@ yarn build
请先完成前端编译,再回到项目的根目录执行以下命令。
```shell
go build -o nginx-ui -v main.go
go build -tags=jsoniter -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/settings.buildTime=$(date +%s)'" -o nginx-ui -v main.go
```
## Linux 安装脚本
@ -240,20 +239,20 @@ go build -o nginx-ui -v main.go
**安装或升级**
```shell
bash <(curl -L -s https://ghproxy.com/https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) install -r https://ghproxy.com/
bash <(curl -L -s https://mirror.ghproxy.com/https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) install -r https://mirror.ghproxy.com/
```
一键安装脚本默认设置的监听端口为 `9000`,HTTP Challenge 端口默认为 `9180`,如果出现端口冲突请进入 `/usr/local/etc/nginx-ui/app.ini` 修改,并使用 `systemctl restart nginx-ui` 重启 Nginx UI 服务。
**卸载 Nginx UI 但保留配置和数据库文件**
```shell
bash <(curl -L -s https://ghproxy.com/https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) remove
bash <(curl -L -s https://mirror.ghproxy.com/https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) remove
```
### 更多用法
````shell
bash <(curl -L -s https://ghproxy.com/https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) help
bash <(curl -L -s https://mirror.ghproxy.com/https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) help
````
## Nginx 反向代理配置示例
@ -273,8 +272,9 @@ map $http_upgrade $connection_upgrade {
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name <your_server_name>;

@ -6,11 +6,11 @@
Yet another Nginx Web UI
Nginx 網路管理介面,由 [0xJacky](https://jackyu.cn/) 與 [Hintay](https://blog.kugeek.com/) 開發。
Nginx 網路管理介面,由 [0xJacky](https://jackyu.cn/) 與 [Hintay](https://blog.kugeek.com/) 開發。
[![Build and Publish](https://github.com/0xJacky/nginx-ui/actions/workflows/build.yml/badge.svg)](https://github.com/0xJacky/nginx-ui/actions/workflows/build.yml)
[English](README.md) | [简体中文](README-zh_CN.md) | 繁體中文
[English](README.md) | [Español](README-es.md) | [简体中文](README-zh_CN.md) | 繁體中文
<details>
<summary>目錄</summary>
@ -21,7 +21,7 @@ Nginx 網路管理介面,由 [0xJacky](https://jackyu.cn/) 與 [Hintay](https
<li><a href="#線上預覽">線上預覽</a></li>
<li><a href="#特色">特色</a></li>
<li><a href="#國際化">國際化</a></li>
<li><a href="#構建基於">構建基於</a></li>
<li><a href="#建置基於">建置基於</a></li>
</ul>
</li>
<li>
@ -40,21 +40,21 @@ Nginx 網路管理介面,由 [0xJacky](https://jackyu.cn/) 與 [Hintay](https
</ul>
</li>
<li>
<a href="#手動構建">手動構建</a>
<a href="#手動建置">手動建置</a>
<ul>
<li><a href="#依賴">依賴</a></li>
<li><a href="#構建前端">構建前端</a></li>
<li><a href="#構建後端">構建後端</a></li>
<li><a href="#相依性">相依性</a></li>
<li><a href="#建置前端">建置前端</a></li>
<li><a href="#建置後端">建置後端</a></li>
</ul>
</li>
<li>
<a href="#linux-安裝指令碼">Linux 安裝指令碼</a>
<a href="#linux-安裝指令">Linux 安裝指令</a>
<ul>
<li><a href="#基本用法">基本用法</a></li>
<li><a href="#更多用法">更多用法</a></li>
</ul>
</li>
<li><a href="#nginx-反向代理配置示例">Nginx 反向代理配置示例</a></li>
<li><a href="#nginx-反向代理設定範例">Nginx 反向代理設定範例</a></li>
<li><a href="#貢獻">貢獻</a></li>
<li><a href="#開源軟體授權條款">開源軟體授權條款</a></li>
</ol>
@ -67,7 +67,7 @@ Nginx 網路管理介面,由 [0xJacky](https://jackyu.cn/) 與 [Hintay](https
### 線上預覽
位址:[https://demo.nginxui.com](https://demo.nginxui.com)
網址:[https://demo.nginxui.com](https://demo.nginxui.com)
- 使用者:admin
- 密碼:admin
@ -77,11 +77,11 @@ Nginx 網路管理介面,由 [0xJacky](https://jackyu.cn/) 與 [Hintay](https
- 線上檢視伺服器 CPU、記憶體、系統負載、磁碟使用率等指標
- 線上 ChatGPT 助理
- 一鍵申請和自動續簽 Let's encrypt 憑證
- 線上編輯 Nginx 配置檔案,編輯器支援 Nginx 配置語法突顯
- 線上查看 Nginx 日誌
- 線上編輯 Nginx 設定檔,編輯器支援 Nginx 設定語法醒目提示
- 線上檢視 Nginx 日誌
- 使用 Go 和 Vue 開發,發行版本為單個可執行檔案
- 保存配置後自動測試配置檔案並重載 Nginx
- 基於網頁瀏覽器的高級命令行終端
- 儲存設定後自動測試設定檔並重新載入 Nginx
- 基於網頁瀏覽器的高階命令列終端
- 支援暗黑模式
- 自適應網頁設計
@ -93,7 +93,8 @@ Nginx 網路管理介面,由 [0xJacky](https://jackyu.cn/) 與 [Hintay](https
我們歡迎您將專案翻譯成任何語言。
### 構建基於
### 建置基於
- [The Go Programming Language](https://go.dev)
- [Gin Web Framework](https://gin-gonic.com)
- [GORM](http://gorm.io)
@ -109,9 +110,9 @@ Nginx 網路管理介面,由 [0xJacky](https://jackyu.cn/) 與 [Hintay](https
### 使用前注意
Nginx UI 遵循 Debian 的網頁伺服器配置檔案標準。建立的網站配置檔案將會放置於 Nginx 配置資料夾(自動檢測)下的 `sites-available` 中,啟用後的網站將會建立一份配置檔案軟連結檔到 `sites-enabled` 資料夾。您可能需要提前調整配置檔案的組織方式。
Nginx UI 遵循 Debian 的網頁伺服器設定檔標準。建立的網站設定檔將會放置於 Nginx 設定資料夾(自動檢測)下的 `sites-available` 中,啟用後的網站將會建立一份設定檔軟連結檔到 `sites-enabled` 資料夾。您可能需要提前調整設定檔的組織方式。
對於非 Debian (及 Ubuntu) 作業系統,您可能需要將 `nginx.conf` 配置檔案中的內容修改為如下所示的 Debian 風格。
對於非 Debian (及 Ubuntu) 作業系統,您可能需要將 `nginx.conf` 設定檔中的內容修改為如下所示的 Debian 風格。
```nginx
http {
@ -127,7 +128,7 @@ http {
Nginx UI 可在以下作業系統中使用:
- Mac OS X 10.10 Yosemite 及之後版本(amd64 / arm64)
- macOS 11 Big Sur 及之後版本(amd64 / arm64)
- Linux 2.6.23 及之後版本(x86 / amd64 / arm64 / armv5 / armv6 / armv7)
- 包括但不限於 Debian 7 / 8、Ubuntu 12.04 / 14.04 及後續版本、CentOS 6 / 7、Arch Linux
- FreeBSD
@ -135,13 +136,14 @@ Nginx UI 可在以下作業系統中使用:
- Dragonfly BSD
- Openwrt
您可以在 [最新释出 (latest release)](https://github.com/0xJacky/nginx-ui/releases/latest) 中下載最新版本,或使用 [Linux 安裝指令碼](#linux-安裝指令碼)。
您可以在 [最新釋出 (latest release)](https://github.com/0xJacky/nginx-ui/releases/latest) 中下載最新版本,或使用 [Linux 安裝指令](#linux-安裝指令)。
### 使用方法
第一次執行 Nginx UI 時,請在網頁瀏覽器中訪問 `http://<your_server_ip>:<listen_port>/install` 完成後續配置。
第一次執行 Nginx UI 時,請在網頁瀏覽器中訪問 `http://<your_server_ip>:<listen_port>` 完成後續設定。
#### 透過執行檔案執行
**在終端中執行 Nginx UI**
```shell
@ -154,24 +156,29 @@ nginx-ui -config app.ini
```shell
nohup ./nginx-ui -config app.ini &
```
使用以下命令停止 Nginx UI。
```shell
kill -9 $(ps -aux | grep nginx-ui | grep -v grep | awk '{print $2}')
```
#### 使用 Systemd
如果你使用的是 [Linux 安裝指令碼](#linux-安裝指令碼),Nginx UI 將作為 `nginx-ui` 守護行程安裝在 systemd 中。請使用 `systemctl` 指令控制。
如果你使用的是 [Linux 安裝指令](#linux-安裝指令),Nginx UI 將作為 `nginx-ui` 守護行程安裝在 systemd 中。請使用 `systemctl` 指令控制。
**啟動 Nginx UI**
```shell
systemctl start nginx-ui
```
**停止 Nginx UI**
```shell
systemctl stop nginx-ui
```
**重啟 Nginx UI**
```shell
@ -180,11 +187,11 @@ systemctl restart nginx-ui
#### 使用 Docker
您可以在 docker 中使用我們提供的 `uozi/nginx-ui:latest` [鏡像](https://hub.docker.com/r/uozi/nginx-ui),此鏡像基於 `nginx:latest` 構建。您可以直接將其監聽到 80 和 443 埠以取代宿主機上的 Nginx。
您可以在 docker 中使用我們提供的 `uozi/nginx-ui:latest` [映象](https://hub.docker.com/r/uozi/nginx-ui),此映象基於 `nginx:latest` 建置。您可以直接將其監聽到 80 和 443 埠以取代宿主機上的 Nginx。
注意:映射到 `/etc/nginx` 的資料夾應是一個空資料夾。
注意:對映到 `/etc/nginx` 的資料夾應是一個空資料夾。
**Docker 示例**
**Docker 範例**
```bash
docker run -dit \
@ -197,41 +204,40 @@ docker run -dit \
uozi/nginx-ui:latest
```
## 手動構建
## 手動建置
對於沒有官方構建版本的作業系統,可以嘗試手動構建。
對於沒有官方建置版本的作業系統,可以嘗試手動建置。
### 依賴
### 相依性
- Make
- Golang 1.18+
- Golang 1.23+
- node.js 14+
- node.js 21+
```shell
npx browserslist@latest --update-db
```
### 構建前端
### 建置前端
請在 `frontend` 資料夾中執行以下命令。
請在 `app` 資料夾中執行以下命令。
```shell
yarn install
make translations
yarn build
pnpm install
pnpm build
```
### 構建後端
### 建置後端
請先完成前端編譯,再回到專案的根目錄執行以下命令。
```shell
go build -o nginx-ui -v main.go
go build -tags=jsoniter -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/settings.buildTime=$(date +%s)'" -o nginx-ui -v main.go
```
## Linux 安裝指令碼
## Linux 安裝指令
### 基本用法
@ -240,9 +246,10 @@ go build -o nginx-ui -v main.go
```shell
bash <(curl -L -s https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) install
```
一鍵安裝指令碼預設的監聽埠為 `9000`,HTTP Challenge 埠預設為 `9180`,如果出現埠衝突請修改 `/usr/local/etc/nginx-ui/app.ini`,並使用 `systemctl restart nginx-ui` 重啟 Nginx UI 守護行程。
**解除安裝 Nginx UI 但保留配置和資料庫檔案**
一鍵安裝指令預設的監聽連接埠為 `9000`,HTTP Challenge 埠預設為 `9180`,如果出現連接埠衝突請修改 `/usr/local/etc/nginx-ui/app.ini`,並使用 `systemctl restart nginx-ui` 重啟 Nginx UI 守護行程。
**解除安裝 Nginx UI 但保留設定和資料庫檔案**
```shell
bash <(curl -L -s https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) remove
@ -254,7 +261,7 @@ bash <(curl -L -s https://raw.githubusercontent.com/0xJacky/nginx-ui/master/inst
bash <(curl -L -s https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) help
````
## Nginx 反向代理配置示例
## Nginx 反向代理設定範例
```nginx
server {
@ -271,8 +278,9 @@ map $http_upgrade $connection_upgrade {
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name <your_server_name>;
@ -306,4 +314,4 @@ server {
## 開源軟體授權條款
此專案基於 GNU Affero Public License v3.0 (AGPLv3) 授權條款,請參閱 [LICENSE](LICENSE) 檔案。透過使用、分發或對本專案做出貢獻,表明您已同意本許可證的條款和條件。
此專案基於 GNU Affero Public License v3.0 (AGPLv3) 授權條款,請參閱 [LICENSE](LICENSE) 檔案。透過使用、散佈或對本專案做出貢獻,表明您已同意本授權條款的條款和條件。

@ -7,6 +7,18 @@
Yet another Nginx Web UI, developed by [0xJacky](https://jackyu.cn/) and [Hintay](https://blog.kugeek.com/).
[![Build and Publish](https://github.com/0xJacky/nginx-ui/actions/workflows/build.yml/badge.svg)](https://github.com/0xJacky/nginx-ui/actions/workflows/build.yml)
[![GitHub license](https://img.shields.io/github/license/0xJacky/nginx-ui?label=License&logo=github)](https://github.com/0xJacky/nginx-ui "Click to view the repo on Github")
[![Release Version](https://img.shields.io/github/release/0xJacky/nginx-ui?include_prereleases&label=Release&logo=github)](https://github.com/0xJacky/nginx-ui/releases/latest "Click to view the repo on Github")
[![GitHub Star](https://img.shields.io/github/stars/0xJacky/nginx-ui?label=Stars&logo=github)](https://github.com/0xJacky/nginx-ui "Click to view the repo on Github")
[![GitHub Fork](https://img.shields.io/github/forks/0xJacky/nginx-ui?label=Forks&logo=github)](https://github.com/0xJacky/nginx-ui "Click to view the repo on Github")
[![Repo Size](https://img.shields.io/github/repo-size/0xJacky/nginx-ui?label=Size&logo=github)](https://github.com/0xJacky/nginx-ui "Click to view the repo on Github")
[![GitHub Fork](https://img.shields.io/github/issues-closed-raw/0xJacky/nginx-ui?label=Closed%20Issue&logo=github)](https://github.com/0xJacky/nginx-ui/issue "Click to view the repo on Github")
[![Docker Stars](https://img.shields.io/docker/stars/uozi/nginx-ui?label=Stars&logo=docker)](https://hub.docker.com/r/uozi/nginx-ui "Click to view the image on Docker Hub")
[![Docker Pulls](https://img.shields.io/docker/pulls/uozi/nginx-ui?label=Pulls&logo=docker)](https://hub.docker.com/r/uozi/nginx-ui "Click to view the image on Docker Hub")
[![Image Size](https://img.shields.io/docker/image-size/uozi/nginx-ui/latest?label=Image%20Size&logo=docker)](https://hub.docker.com/r/uozi/nginx-ui "Click to view the image on Docker Hub")
[![Translated Status](https://weblate.nginxui.com/widget/nginx-ui/frontend/svg-badge.svg)](https://weblate.nginxui.com/engage/nginx-ui/)
## Documentation
To check out docs, visit [nginxui.com](https://nginxui.com).
@ -15,8 +27,7 @@ To check out docs, visit [nginxui.com](https://nginxui.com).
[![Stargazers over time](https://starchart.cc/0xJacky/nginx-ui.svg)](https://starchart.cc/0xJacky/nginx-ui)
English | [简体中文](README-zh_CN.md) | [繁體中文](README-zh_TW.md)
English | [Español](README-es.md) | [简体中文](README-zh_CN.md) | [繁體中文](README-zh_TW.md) | [Tiếng Việt](README-vi_VN.md)
<details>
<summary>Table of Contents</summary>
@ -49,7 +60,7 @@ English | [简体中文](README-zh_CN.md) | [繁體中文](README-zh_TW.md)
<a href="#manual-build">Manual Build</a>
<ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#build-frontend">Build Frontend</a></li>
<li><a href="#build-app">Build Frontend</a></li>
<li><a href="#build-backend">Build Backend</a></li>
</ul>
</li>
@ -66,7 +77,6 @@ English | [简体中文](README-zh_CN.md) | [繁體中文](README-zh_TW.md)
</ol>
</details>
## About The Project
![Dashboard](resources/screenshots/dashboard_en.png)
@ -132,7 +142,7 @@ For more information: [debian/conf/nginx.conf](https://salsa.debian.org/nginx-te
Nginx UI is available on the following platforms:
- Mac OS X 10.10 Yosemite and later (amd64 / arm64)
- macOS 11 Big Sur and later (amd64 / arm64)
- Linux 2.6.23 and later (x86 / amd64 / arm64 / armv5 / armv6 / armv7)
- Including but not limited to Debian 7 / 8, Ubuntu 12.04 / 14.04 and later, CentOS 6 / 7, Arch Linux
- FreeBSD
@ -144,7 +154,7 @@ You can visit [latest release](https://github.com/0xJacky/nginx-ui/releases/late
### Usage
In the first runtime of Nginx UI, please visit `http://<your_server_ip>:<listen_port>/install`
In the first runtime of Nginx UI, please visit `http://<your_server_ip>:<listen_port>`
in your browser to complete the follow-up configurations.
#### From Executable
@ -160,11 +170,12 @@ Press `Control+C` in the terminal to exit Nginx UI.
```shell
nohup ./nginx-ui -config app.ini &
```
Stop Nginx UI with the follow commond.
Stop Nginx UI with the follow command.
```shell
kill -9 $(ps -aux | grep nginx-ui | grep -v grep | awk '{print $2}')
```
#### With Systemd
If you are using the [installation script for Linux](#script-for-linux), the Nginx UI will be installed as `nginx-ui` service in systemd. Please use the `systemctl` command to control it.
@ -193,7 +204,12 @@ you can easily make the switch.
1. When using this container for the first time, ensure that the volume mapped to /etc/nginx is empty.
2. If you want to host static files, you can map directories to container.
**Docker Deploy Example**
<details>
<summary><b>Deploy with Docker</b></summary>
1. [Install Docker.](https://docs.docker.com/install/)
2. Then deploy nginx-ui like this:
```bash
docker run -dit \
@ -202,11 +218,55 @@ docker run -dit \
-e TZ=Asia/Shanghai \
-v /mnt/user/appdata/nginx:/etc/nginx \
-v /mnt/user/appdata/nginx-ui:/etc/nginx-ui \
-v /var/www:/var/www \
-p 8080:80 -p 8443:443 \
uozi/nginx-ui:latest
```
3. When your docker container is running, Log in to nginx-ui panel with `http://<your_server_ip>:8080/install`.
</details>
<details>
<summary><b>Deploy with Docker-Compose</b></summary>
1. [Install Docker-Compose.](https://docs.docker.com/compose/install/)
2. Create a docker-compose.yml file like this:
```yml
version: '3.3'
services:
nginx-ui:
stdin_open: true
tty: true
container_name: nginx-ui
restart: always
environment:
- TZ=Asia/Shanghai
volumes:
- '/mnt/user/appdata/nginx:/etc/nginx'
- '/mnt/user/appdata/nginx-ui:/etc/nginx-ui'
- '/var/www:/var/www'
ports:
- 8080:80
- 8443:443
image: 'uozi/nginx-ui:latest'
```
3. Then creat your container by:
```bash
docker-compose up -d
```
```bash
# If using docker-compose-plugin
docker compose up -d
```
4. When your docker container is running, Log in to nginx-ui panel with `http://<your_server_ip>:8080/install`.
</details>
## Manual Build
On platforms that do not have an official build version, they can be built manually.
@ -215,9 +275,9 @@ On platforms that do not have an official build version, they can be built manua
- Make
- Golang 1.19+
- Golang 1.23+
- node.js 18+
- node.js 21+
```shell
npx browserslist@latest --update-db
@ -225,19 +285,19 @@ On platforms that do not have an official build version, they can be built manua
### Build Frontend
Please execute the following command in `frontend` directory.
Please execute the following command in `app` directory.
```shell
yarn install
yarn build
pnpm install
pnpm build
```
### Build Backend
Please build the frontend first, and then execute the following command in the project root directory.
Please build the app first, and then execute the following command in the project root directory.
```shell
go build -o nginx-ui -v main.go
go build -tags=jsoniter -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/settings.buildTime=$(date +%s)'" -o nginx-ui -v main.go
```
## Script for Linux
@ -282,8 +342,9 @@ map $http_upgrade $connection_upgrade {
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name <your_server_name>;

@ -0,0 +1,147 @@
package analytic
import (
"fmt"
"github.com/0xJacky/Nginx-UI/internal/analytic"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/host"
"github.com/shirou/gopsutil/v3/load"
"github.com/shirou/gopsutil/v3/net"
"github.com/spf13/cast"
"net/http"
"runtime"
"time"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
)
func Analytic(c *gin.Context) {
var upGrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
// upgrade http to websocket
ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
logger.Error(err)
return
}
defer ws.Close()
var stat Stat
for {
stat.Memory, err = analytic.GetMemoryStat()
if err != nil {
logger.Error(err)
return
}
cpuTimesBefore, _ := cpu.Times(false)
time.Sleep(1000 * time.Millisecond)
cpuTimesAfter, _ := cpu.Times(false)
threadNum := runtime.GOMAXPROCS(0)
cpuUserUsage := (cpuTimesAfter[0].User - cpuTimesBefore[0].User) / (float64(1000*threadNum) / 1000)
cpuSystemUsage := (cpuTimesAfter[0].System - cpuTimesBefore[0].System) / (float64(1000*threadNum) / 1000)
stat.CPU = CPUStat{
User: cast.ToFloat64(fmt.Sprintf("%.2f", cpuUserUsage*100)),
System: cast.ToFloat64(fmt.Sprintf("%.2f", cpuSystemUsage*100)),
Idle: cast.ToFloat64(fmt.Sprintf("%.2f", (1-cpuUserUsage-cpuSystemUsage)*100)),
Total: cast.ToFloat64(fmt.Sprintf("%.2f", (cpuUserUsage+cpuSystemUsage)*100)),
}
stat.Uptime, _ = host.Uptime()
stat.LoadAvg, _ = load.Avg()
stat.Disk, err = analytic.GetDiskStat()
if err != nil {
logger.Error(err)
return
}
network, _ := net.IOCounters(false)
if len(network) > 0 {
stat.Network = network[0]
}
// write
err = ws.WriteJSON(stat)
if helper.IsUnexpectedWebsocketError(err) {
logger.Error(err)
break
}
time.Sleep(800 * time.Microsecond)
}
}
func GetAnalyticInit(c *gin.Context) {
cpuInfo, err := cpu.Info()
if err != nil {
logger.Error(err)
}
network, err := net.IOCounters(false)
if err != nil {
logger.Error(err)
}
memory, err := analytic.GetMemoryStat()
if err != nil {
logger.Error(err)
}
diskStat, err := analytic.GetDiskStat()
if err != nil {
logger.Error(err)
}
var _net net.IOCountersStat
if len(network) > 0 {
_net = network[0]
}
hostInfo, _ := host.Info()
switch hostInfo.Platform {
case "ubuntu":
hostInfo.Platform = "Ubuntu"
case "centos":
hostInfo.Platform = "CentOS"
}
loadAvg, err := load.Avg()
if err != nil {
logger.Error(err)
}
c.JSON(http.StatusOK, InitResp{
Host: hostInfo,
CPU: CPURecords{
Info: cpuInfo,
User: analytic.CpuUserRecord,
Total: analytic.CpuTotalRecord,
},
Network: NetworkRecords{
Init: _net,
BytesRecv: analytic.NetRecvRecord,
BytesSent: analytic.NetSentRecord,
},
DiskIO: DiskIORecords{
Writes: analytic.DiskWriteRecord,
Reads: analytic.DiskReadRecord,
},
Memory: memory,
Disk: diskStat,
LoadAvg: loadAvg,
})
}

@ -0,0 +1,65 @@
package analytic
import (
"github.com/0xJacky/Nginx-UI/internal/analytic"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"net/http"
"time"
)
func GetNodeStat(c *gin.Context) {
var upGrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
// upgrade http to websocket
ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
logger.Error(err)
return
}
defer ws.Close()
for {
// write
err = ws.WriteJSON(analytic.GetNodeStat())
if helper.IsUnexpectedWebsocketError(err) {
logger.Error(err)
break
}
time.Sleep(10 * time.Second)
}
}
func GetNodesAnalytic(c *gin.Context) {
var upGrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
// upgrade http to websocket
ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
logger.Error(err)
return
}
defer ws.Close()
for {
// write
err = ws.WriteJSON(analytic.NodeMap)
if helper.IsUnexpectedWebsocketError(err) {
logger.Error(err)
break
}
time.Sleep(10 * time.Second)
}
}

@ -0,0 +1,15 @@
package analytic
import (
"github.com/gin-gonic/gin"
)
func InitWebSocketRouter(r *gin.RouterGroup) {
r.GET("analytic", Analytic)
r.GET("analytic/intro", GetNodeStat)
r.GET("analytic/nodes", GetNodesAnalytic)
}
func InitRouter(r *gin.RouterGroup) {
r.GET("analytic/init", GetAnalyticInit)
}

@ -0,0 +1,52 @@
package analytic
import (
"github.com/0xJacky/Nginx-UI/internal/analytic"
"github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/host"
"github.com/shirou/gopsutil/v3/load"
"github.com/shirou/gopsutil/v3/net"
)
type CPUStat struct {
User float64 `json:"user"`
System float64 `json:"system"`
Idle float64 `json:"idle"`
Total float64 `json:"total"`
}
type Stat struct {
Uptime uint64 `json:"uptime"`
LoadAvg *load.AvgStat `json:"loadavg"`
CPU CPUStat `json:"cpu"`
Memory analytic.MemStat `json:"memory"`
Disk analytic.DiskStat `json:"disk"`
Network net.IOCountersStat `json:"network"`
}
type CPURecords struct {
Info []cpu.InfoStat `json:"info"`
User []analytic.Usage[float64] `json:"user"`
Total []analytic.Usage[float64] `json:"total"`
}
type NetworkRecords struct {
Init net.IOCountersStat `json:"init"`
BytesRecv []analytic.Usage[uint64] `json:"bytesRecv"`
BytesSent []analytic.Usage[uint64] `json:"bytesSent"`
}
type DiskIORecords struct {
Writes []analytic.Usage[uint64] `json:"writes"`
Reads []analytic.Usage[uint64] `json:"reads"`
}
type InitResp struct {
Host *host.InfoStat `json:"host"`
CPU CPURecords `json:"cpu"`
Network NetworkRecords `json:"network"`
DiskIO DiskIORecords `json:"disk_io"`
Memory analytic.MemStat `json:"memory"`
Disk analytic.DiskStat `json:"disk"`
LoadAvg *load.AvgStat `json:"loadavg"`
}

@ -0,0 +1,127 @@
package api
import (
"errors"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/model"
"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
"net/http"
"reflect"
"regexp"
"strings"
)
func CurrentUser(c *gin.Context) *model.User {
return c.MustGet("user").(*model.User)
}
func ErrHandler(c *gin.Context, err error) {
logger.GetLogger().Errorln(err)
c.JSON(http.StatusInternalServerError, gin.H{
"message": err.Error(),
})
}
type ValidError struct {
Key string
Message string
}
func BindAndValid(c *gin.Context, target interface{}) bool {
err := c.ShouldBindJSON(target)
if err != nil {
logger.Error("bind err", err)
var verrs validator.ValidationErrors
ok := errors.As(err, &verrs)
if !ok {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "Requested with wrong parameters",
"code": http.StatusNotAcceptable,
})
return false
}
t := reflect.TypeOf(target).Elem()
errorsMap := make(map[string]interface{})
for _, value := range verrs {
var path []string
namespace := strings.Split(value.StructNamespace(), ".")
// logger.Debug(t.Name(), namespace)
if t.Name() != "" && len(namespace) > 1 {
namespace = namespace[1:]
}
getJsonPath(t, namespace, &path)
insertError(errorsMap, path, value.Tag())
}
c.JSON(http.StatusNotAcceptable, gin.H{
"errors": errorsMap,
"message": "Requested with wrong parameters",
"code": http.StatusNotAcceptable,
})
return false
}
return true
}
// findField recursively finds the field in a nested struct
func getJsonPath(t reflect.Type, fields []string, path *[]string) {
field := fields[0]
// used in case of array
var index string
if field[len(field)-1] == ']' {
re := regexp.MustCompile(`(\w+)\[(\d+)\]`)
matches := re.FindStringSubmatch(field)
if len(matches) > 2 {
field = matches[1]
index = matches[2]
}
}
f, ok := t.FieldByName(field)
if !ok {
return
}
*path = append(*path, f.Tag.Get("json"))
if index != "" {
*path = append(*path, index)
}
if len(fields) > 1 {
subFields := fields[1:]
getJsonPath(f.Type, subFields, path)
}
}
// insertError inserts an error into the errors map
func insertError(errorsMap map[string]interface{}, path []string, errorTag string) {
if len(path) == 0 {
return
}
jsonTag := path[0]
if len(path) == 1 {
// Last element in the path, set the error
errorsMap[jsonTag] = errorTag
return
}
// Create a new map if necessary
if _, ok := errorsMap[jsonTag]; !ok {
errorsMap[jsonTag] = make(map[string]interface{})
}
// Recursively insert into the nested map
subMap, _ := errorsMap[jsonTag].(map[string]interface{})
insertError(subMap, path[1:], errorTag)
}

@ -0,0 +1,96 @@
package certificate
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/cosy"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/spf13/cast"
"net/http"
)
func GetAcmeUser(c *gin.Context) {
u := query.AcmeUser
id := cast.ToInt(c.Param("id"))
user, err := u.FirstByID(id)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, user)
}
func CreateAcmeUser(c *gin.Context) {
cosy.Core[model.AcmeUser](c).SetValidRules(gin.H{
"name": "required",
"email": "required,email",
"ca_dir": "omitempty",
}).BeforeExecuteHook(func(ctx *cosy.Ctx[model.AcmeUser]) {
if ctx.Model.CADir == "" {
ctx.Model.CADir = settings.ServerSettings.GetCADir()
}
err := ctx.Model.Register()
if err != nil {
ctx.AbortWithError(err)
return
}
}).Create()
}
func ModifyAcmeUser(c *gin.Context) {
cosy.Core[model.AcmeUser](c).SetValidRules(gin.H{
"name": "omitempty",
"email": "omitempty,email",
"ca_dir": "omitempty",
}).BeforeExecuteHook(func(ctx *cosy.Ctx[model.AcmeUser]) {
if ctx.Model.CADir == "" {
ctx.Model.CADir = settings.ServerSettings.GetCADir()
}
if ctx.OriginModel.Email != ctx.Model.Email ||
ctx.OriginModel.CADir != ctx.Model.CADir {
err := ctx.Model.Register()
if err != nil {
ctx.AbortWithError(err)
return
}
}
}).Modify()
}
func GetAcmeUserList(c *gin.Context) {
cosy.Core[model.AcmeUser](c).
SetFussy("name", "email").
PagingList()
}
func DestroyAcmeUser(c *gin.Context) {
cosy.Core[model.AcmeUser](c).Destroy()
}
func RecoverAcmeUser(c *gin.Context) {
cosy.Core[model.AcmeUser](c).Recover()
}
func RegisterAcmeUser(c *gin.Context) {
id := cast.ToInt(c.Param("id"))
u := query.AcmeUser
user, err := u.FirstByID(id)
if err != nil {
api.ErrHandler(c, err)
return
}
err = user.Register()
if err != nil {
api.ErrHandler(c, err)
return
}
_, err = u.Where(u.ID.Eq(id)).Updates(user)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, user)
}

@ -0,0 +1,243 @@
package certificate
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/cert"
"github.com/0xJacky/Nginx-UI/internal/cosy"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/internal/notification"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"github.com/go-acme/lego/v4/certcrypto"
"github.com/spf13/cast"
"net/http"
"os"
)
type APICertificate struct {
*model.Cert
SSLCertificate string `json:"ssl_certificate,omitempty"`
SSLCertificateKey string `json:"ssl_certificate_key,omitempty"`
CertificateInfo *cert.Info `json:"certificate_info,omitempty"`
}
func Transformer(certModel *model.Cert) (certificate *APICertificate) {
var sslCertificationBytes, sslCertificationKeyBytes []byte
var certificateInfo *cert.Info
if certModel.SSLCertificatePath != "" &&
helper.IsUnderDirectory(certModel.SSLCertificatePath, nginx.GetConfPath()) {
if _, err := os.Stat(certModel.SSLCertificatePath); err == nil {
sslCertificationBytes, _ = os.ReadFile(certModel.SSLCertificatePath)
if !cert.IsCertificate(string(sslCertificationBytes)) {
sslCertificationBytes = []byte{}
}
}
certificateInfo, _ = cert.GetCertInfo(certModel.SSLCertificatePath)
}
if certModel.SSLCertificateKeyPath != "" &&
helper.IsUnderDirectory(certModel.SSLCertificateKeyPath, nginx.GetConfPath()) {
if _, err := os.Stat(certModel.SSLCertificateKeyPath); err == nil {
sslCertificationKeyBytes, _ = os.ReadFile(certModel.SSLCertificateKeyPath)
if !cert.IsPrivateKey(string(sslCertificationKeyBytes)) {
sslCertificationKeyBytes = []byte{}
}
}
}
return &APICertificate{
Cert: certModel,
SSLCertificate: string(sslCertificationBytes),
SSLCertificateKey: string(sslCertificationKeyBytes),
CertificateInfo: certificateInfo,
}
}
func GetCertList(c *gin.Context) {
cosy.Core[model.Cert](c).SetFussy("name", "domain").SetTransformer(func(m *model.Cert) any {
info, _ := cert.GetCertInfo(m.SSLCertificatePath)
return APICertificate{
Cert: m,
CertificateInfo: info,
}
}).PagingList()
}
func GetCert(c *gin.Context) {
q := query.Cert
certModel, err := q.FirstByID(cast.ToInt(c.Param("id")))
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, Transformer(certModel))
}
type certJson struct {
Name string `json:"name" binding:"required"`
SSLCertificatePath string `json:"ssl_certificate_path" binding:"required,certificate_path"`
SSLCertificateKeyPath string `json:"ssl_certificate_key_path" binding:"required,privatekey_path"`
SSLCertificate string `json:"ssl_certificate" binding:"omitempty,certificate"`
SSLCertificateKey string `json:"ssl_certificate_key" binding:"omitempty,privatekey"`
KeyType certcrypto.KeyType `json:"key_type" binding:"omitempty,auto_cert_key_type"`
ChallengeMethod string `json:"challenge_method"`
DnsCredentialID int `json:"dns_credential_id"`
ACMEUserID int `json:"acme_user_id"`
SyncNodeIds []int `json:"sync_node_ids"`
}
func AddCert(c *gin.Context) {
var json certJson
if !api.BindAndValid(c, &json) {
return
}
certModel := &model.Cert{
Name: json.Name,
SSLCertificatePath: json.SSLCertificatePath,
SSLCertificateKeyPath: json.SSLCertificateKeyPath,
KeyType: json.KeyType,
ChallengeMethod: json.ChallengeMethod,
DnsCredentialID: json.DnsCredentialID,
ACMEUserID: json.ACMEUserID,
SyncNodeIds: json.SyncNodeIds,
}
err := certModel.Insert()
if err != nil {
api.ErrHandler(c, err)
return
}
content := &cert.Content{
SSLCertificatePath: json.SSLCertificatePath,
SSLCertificateKeyPath: json.SSLCertificateKeyPath,
SSLCertificate: json.SSLCertificate,
SSLCertificateKey: json.SSLCertificateKey,
}
err = content.WriteFile()
if err != nil {
api.ErrHandler(c, err)
return
}
err = cert.SyncToRemoteServer(certModel)
if err != nil {
notification.Error("Sync Certificate Error", err.Error())
return
}
c.JSON(http.StatusOK, Transformer(certModel))
}
func ModifyCert(c *gin.Context) {
id := cast.ToInt(c.Param("id"))
var json certJson
if !api.BindAndValid(c, &json) {
return
}
q := query.Cert
certModel, err := q.FirstByID(id)
if err != nil {
api.ErrHandler(c, err)
return
}
err = certModel.Updates(&model.Cert{
Name: json.Name,
SSLCertificatePath: json.SSLCertificatePath,
SSLCertificateKeyPath: json.SSLCertificateKeyPath,
ChallengeMethod: json.ChallengeMethod,
KeyType: json.KeyType,
DnsCredentialID: json.DnsCredentialID,
ACMEUserID: json.ACMEUserID,
SyncNodeIds: json.SyncNodeIds,
})
if err != nil {
api.ErrHandler(c, err)
return
}
content := &cert.Content{
SSLCertificatePath: json.SSLCertificatePath,
SSLCertificateKeyPath: json.SSLCertificateKeyPath,
SSLCertificate: json.SSLCertificate,
SSLCertificateKey: json.SSLCertificateKey,
}
err = content.WriteFile()
if err != nil {
api.ErrHandler(c, err)
return
}
err = cert.SyncToRemoteServer(certModel)
if err != nil {
notification.Error("Sync Certificate Error", err.Error())
return
}
GetCert(c)
}
func RemoveCert(c *gin.Context) {
cosy.Core[model.Cert](c).Destroy()
}
func SyncCertificate(c *gin.Context) {
var json cert.SyncCertificatePayload
if !api.BindAndValid(c, &json) {
return
}
certModel := &model.Cert{
Name: json.Name,
SSLCertificatePath: json.SSLCertificatePath,
SSLCertificateKeyPath: json.SSLCertificateKeyPath,
KeyType: json.KeyType,
AutoCert: model.AutoCertSync,
}
db := model.UseDB()
err := db.Where(certModel).FirstOrCreate(certModel).Error
if err != nil {
api.ErrHandler(c, err)
return
}
content := &cert.Content{
SSLCertificatePath: json.SSLCertificatePath,
SSLCertificateKeyPath: json.SSLCertificateKeyPath,
SSLCertificate: json.SSLCertificate,
SSLCertificateKey: json.SSLCertificateKey,
}
err = content.WriteFile()
if err != nil {
api.ErrHandler(c, err)
return
}
nginx.Reload()
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,105 @@
package certificate
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/cert/dns"
"github.com/0xJacky/Nginx-UI/internal/cosy"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"github.com/spf13/cast"
"net/http"
)
func GetDnsCredential(c *gin.Context) {
id := cast.ToInt(c.Param("id"))
d := query.DnsCredential
dnsCredential, err := d.FirstByID(id)
if err != nil {
api.ErrHandler(c, err)
return
}
type apiDnsCredential struct {
model.Model
Name string `json:"name"`
Provider string `json:"provider"`
dns.Config
}
c.JSON(http.StatusOK, apiDnsCredential{
Model: dnsCredential.Model,
Name: dnsCredential.Name,
Provider: dnsCredential.Provider,
Config: *dnsCredential.Config,
})
}
func GetDnsCredentialList(c *gin.Context) {
cosy.Core[model.DnsCredential](c).SetFussy("provider").PagingList()
}
type DnsCredentialManageJson struct {
Name string `json:"name" binding:"required"`
Provider string `json:"provider"`
dns.Config
}
func AddDnsCredential(c *gin.Context) {
var json DnsCredentialManageJson
if !api.BindAndValid(c, &json) {
return
}
json.Config.Name = json.Provider
dnsCredential := model.DnsCredential{
Name: json.Name,
Config: &json.Config,
Provider: json.Provider,
}
d := query.DnsCredential
err := d.Create(&dnsCredential)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, dnsCredential)
}
func EditDnsCredential(c *gin.Context) {
id := cast.ToInt(c.Param("id"))
var json DnsCredentialManageJson
if !api.BindAndValid(c, &json) {
return
}
d := query.DnsCredential
dnsCredential, err := d.FirstByID(id)
if err != nil {
api.ErrHandler(c, err)
return
}
json.Config.Name = json.Provider
_, err = d.Where(d.ID.Eq(dnsCredential.ID)).Updates(&model.DnsCredential{
Name: json.Name,
Config: &json.Config,
Provider: json.Provider,
})
if err != nil {
api.ErrHandler(c, err)
return
}
GetDnsCredential(c)
}
func DeleteDnsCredential(c *gin.Context) {
cosy.Core[model.DnsCredential](c).Destroy()
}

@ -0,0 +1,27 @@
package certificate
import (
"github.com/0xJacky/Nginx-UI/internal/cert/dns"
"github.com/gin-gonic/gin"
"net/http"
)
func GetDNSProvidersList(c *gin.Context) {
c.JSON(http.StatusOK, dns.GetProvidersList())
}
func GetDNSProvider(c *gin.Context) {
code := c.Param("code")
provider, ok := dns.GetProvider(code)
if !ok {
c.JSON(http.StatusNotFound, gin.H{
"message": "provider not found",
})
return
}
c.JSON(http.StatusOK, provider)
}

@ -0,0 +1,155 @@
package certificate
import (
"github.com/0xJacky/Nginx-UI/internal/cert"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/model"
"github.com/gin-gonic/gin"
"github.com/go-acme/lego/v4/certcrypto"
"github.com/gorilla/websocket"
"net/http"
)
const (
Success = "success"
Info = "info"
Error = "error"
)
type IssueCertResponse struct {
Status string `json:"status"`
Message string `json:"message"`
SSLCertificate string `json:"ssl_certificate,omitempty"`
SSLCertificateKey string `json:"ssl_certificate_key,omitempty"`
KeyType certcrypto.KeyType `json:"key_type"`
}
func handleIssueCertLogChan(conn *websocket.Conn, log *cert.Logger, logChan chan string) {
defer func() {
if err := recover(); err != nil {
logger.Error(err)
}
}()
for logString := range logChan {
log.Info(logString)
err := conn.WriteJSON(IssueCertResponse{
Status: Info,
Message: logString,
})
if err != nil {
logger.Error(err)
return
}
}
}
func IssueCert(c *gin.Context) {
var upGrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
// upgrade http to websocket
ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
logger.Error(err)
return
}
defer func(ws *websocket.Conn) {
_ = ws.Close()
}(ws)
// read
payload := &cert.ConfigPayload{}
err = ws.ReadJSON(payload)
if err != nil {
logger.Error(err)
return
}
certModel, err := model.FirstOrCreateCert(c.Param("name"), payload.GetKeyType())
if err != nil {
logger.Error(err)
return
}
certInfo, _ := cert.GetCertInfo(certModel.SSLCertificatePath)
if certInfo != nil {
payload.Resource = certModel.Resource
payload.NotBefore = certInfo.NotBefore
}
logChan := make(chan string, 1)
errChan := make(chan error, 1)
log := &cert.Logger{}
log.SetCertModel(&certModel)
payload.CertID = certModel.ID
go cert.IssueCert(payload, logChan, errChan)
go handleIssueCertLogChan(ws, log, logChan)
// block, until errChan closes
for err = range errChan {
log.Error(err)
// Save logs to db
log.Exit()
err = ws.WriteJSON(IssueCertResponse{
Status: Error,
Message: err.Error(),
})
if err != nil {
logger.Error(err)
return
}
return
}
err = certModel.Updates(&model.Cert{
Domains: payload.ServerName,
SSLCertificatePath: payload.GetCertificatePath(),
SSLCertificateKeyPath: payload.GetCertificateKeyPath(),
AutoCert: model.AutoCertEnabled,
KeyType: payload.KeyType,
ChallengeMethod: payload.ChallengeMethod,
DnsCredentialID: payload.DNSCredentialID,
Resource: payload.Resource,
MustStaple: payload.MustStaple,
LegoDisableCNAMESupport: payload.LegoDisableCNAMESupport,
})
if err != nil {
logger.Error(err)
_ = ws.WriteJSON(IssueCertResponse{
Status: Error,
Message: err.Error(),
})
return
}
// Save logs to db
log.Exit()
err = ws.WriteJSON(IssueCertResponse{
Status: Success,
Message: "Issued certificate successfully",
SSLCertificate: payload.GetCertificatePath(),
SSLCertificateKey: payload.GetCertificateKeyPath(),
KeyType: payload.GetKeyType(),
})
if err != nil {
logger.Error(err)
return
}
}

@ -0,0 +1,36 @@
package certificate
import "github.com/gin-gonic/gin"
func InitDNSCredentialRouter(r *gin.RouterGroup) {
r.GET("dns_credentials", GetDnsCredentialList)
r.GET("dns_credential/:id", GetDnsCredential)
r.POST("dns_credential", AddDnsCredential)
r.POST("dns_credential/:id", EditDnsCredential)
r.DELETE("dns_credential/:id", DeleteDnsCredential)
}
func InitCertificateRouter(r *gin.RouterGroup) {
r.GET("certs", GetCertList)
r.GET("cert/:id", GetCert)
r.POST("cert", AddCert)
r.POST("cert/:id", ModifyCert)
r.DELETE("cert/:id", RemoveCert)
r.PUT("cert_sync", SyncCertificate)
r.GET("certificate/dns_providers", GetDNSProvidersList)
r.GET("certificate/dns_provider/:code", GetDNSProvider)
}
func InitCertificateWebSocketRouter(r *gin.RouterGroup) {
r.GET("domain/:name/cert", IssueCert)
}
func InitAcmeUserRouter(r *gin.RouterGroup) {
r.GET("acme_users", GetAcmeUserList)
r.GET("acme_user/:id", GetAcmeUser)
r.POST("acme_user", CreateAcmeUser)
r.POST("acme_user/:id", ModifyAcmeUser)
r.POST("acme_user/:id/register", RegisterAcmeUser)
r.DELETE("acme_user/:id", DestroyAcmeUser)
r.PATCH("acme_user/:id", RecoverAcmeUser)
}

@ -0,0 +1,103 @@
package cluster
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/analytic"
"github.com/0xJacky/Nginx-UI/internal/cluster"
"github.com/0xJacky/Nginx-UI/internal/cosy"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/spf13/cast"
"gorm.io/gorm"
"net/http"
)
func GetEnvironment(c *gin.Context) {
id := cast.ToInt(c.Param("id"))
envQuery := query.Environment
env, err := envQuery.FirstByID(id)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, analytic.GetNode(env))
}
func GetEnvironmentList(c *gin.Context) {
core := cosy.Core[model.Environment](c).
SetFussy("name")
// fix for sqlite
if c.Query("enabled") != "" {
core.GormScope(func(tx *gorm.DB) *gorm.DB {
return tx.Where("enabled = ?", cast.ToInt(cast.ToBool(c.Query("enabled"))))
})
}
core.SetTransformer(func(m *model.Environment) any {
return analytic.GetNode(m)
}).PagingList()
}
func AddEnvironment(c *gin.Context) {
cosy.Core[model.Environment](c).SetValidRules(gin.H{
"name": "required",
"url": "required,url",
"token": "required",
"enabled": "omitempty,boolean",
}).ExecutedHook(func(c *cosy.Ctx[model.Environment]) {
go analytic.RestartRetrieveNodesStatus()
}).Create()
}
func EditEnvironment(c *gin.Context) {
cosy.Core[model.Environment](c).SetValidRules(gin.H{
"name": "required",
"url": "required,url",
"token": "required",
"enabled": "omitempty,boolean",
}).ExecutedHook(func(c *cosy.Ctx[model.Environment]) {
go analytic.RestartRetrieveNodesStatus()
}).Modify()
}
func DeleteEnvironment(c *gin.Context) {
id := cast.ToInt(c.Param("id"))
envQuery := query.Environment
env, err := envQuery.FirstByID(id)
if err != nil {
api.ErrHandler(c, err)
return
}
err = envQuery.DeleteByID(env.ID)
if err != nil {
api.ErrHandler(c, err)
return
}
go analytic.RestartRetrieveNodesStatus()
c.JSON(http.StatusNoContent, nil)
}
func LoadEnvironmentFromSettings(c *gin.Context) {
err := settings.ReloadCluster()
if err != nil {
api.ErrHandler(c, err)
return
}
cluster.RegisterPredefinedNodes()
go analytic.RestartRetrieveNodesStatus()
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,46 @@
package cluster
import (
"github.com/0xJacky/Nginx-UI/api"
analytic2 "github.com/0xJacky/Nginx-UI/internal/analytic"
"github.com/0xJacky/Nginx-UI/internal/upgrader"
"github.com/dustin/go-humanize"
"github.com/gin-gonic/gin"
"github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/disk"
"net/http"
)
func GetCurrentNode(c *gin.Context) {
if _, ok := c.Get("NodeSecret"); !ok {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "node secret not exist",
})
return
}
runtimeInfo, err := upgrader.GetRuntimeInfo()
if err != nil {
api.ErrHandler(c, err)
return
}
cpuInfo, _ := cpu.Info()
memory, _ := analytic2.GetMemoryStat()
ver, _ := upgrader.GetCurrentVersion()
diskUsage, _ := disk.Usage(".")
nodeInfo := analytic2.NodeInfo{
NodeRuntimeInfo: runtimeInfo,
CPUNum: len(cpuInfo),
MemoryTotal: memory.Total,
DiskTotal: humanize.Bytes(diskUsage.Total),
Version: ver.Version,
}
stat := analytic2.GetNodeStat()
c.JSON(http.StatusOK, analytic2.Node{
NodeInfo: nodeInfo,
NodeStat: stat,
})
}

@ -0,0 +1,18 @@
package cluster
import "github.com/gin-gonic/gin"
func InitRouter(r *gin.RouterGroup) {
// Environment
r.GET("environments", GetEnvironmentList)
r.POST("environments/load_from_settings", LoadEnvironmentFromSettings)
envGroup := r.Group("environment")
{
envGroup.GET("/:id", GetEnvironment)
envGroup.POST("", AddEnvironment)
envGroup.POST("/:id", EditEnvironment)
envGroup.DELETE("/:id", DeleteEnvironment)
}
// Node
r.GET("node", GetCurrentNode)
}

@ -0,0 +1,97 @@
package config
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/config"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"github.com/sashabaranov/go-openai"
"net/http"
"os"
"path/filepath"
"time"
)
func AddConfig(c *gin.Context) {
var json struct {
Name string `json:"name" binding:"required"`
NewFilepath string `json:"new_filepath" binding:"required"`
Content string `json:"content"`
Overwrite bool `json:"overwrite"`
SyncNodeIds []int `json:"sync_node_ids"`
}
if !api.BindAndValid(c, &json) {
return
}
name := json.Name
content := json.Content
path := json.NewFilepath
if !helper.IsUnderDirectory(path, nginx.GetConfPath()) {
c.JSON(http.StatusForbidden, gin.H{
"message": "new filepath is not under the nginx conf path",
})
return
}
if !json.Overwrite && helper.FileExists(path) {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "File exists",
})
return
}
// check if the dir exists, if not, use mkdirAll to create the dir
dir := filepath.Dir(path)
if !helper.FileExists(dir) {
err := os.MkdirAll(dir, 0755)
if err != nil {
api.ErrHandler(c, err)
return
}
}
err := os.WriteFile(path, []byte(content), 0644)
if err != nil {
api.ErrHandler(c, err)
return
}
output := nginx.Reload()
if nginx.GetLogLevel(output) >= nginx.Warn {
c.JSON(http.StatusInternalServerError, gin.H{
"message": output,
})
return
}
q := query.Config
_, err = q.Where(q.Filepath.Eq(path)).Delete()
if err != nil {
api.ErrHandler(c, err)
return
}
err = q.Create(&model.Config{
Name: name,
Filepath: path,
SyncNodeIds: json.SyncNodeIds,
SyncOverwrite: json.Overwrite,
})
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, config.Config{
Name: name,
Content: content,
ChatGPTMessages: make([]openai.ChatCompletionMessage, 0),
FilePath: path,
ModifiedAt: time.Now(),
})
}

@ -0,0 +1,13 @@
package config
import (
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/gin-gonic/gin"
"net/http"
)
func GetBasePath(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"base_path": nginx.GetConfPath(),
})
}

@ -0,0 +1,72 @@
package config
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/config"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"github.com/sashabaranov/go-openai"
"net/http"
"os"
)
type APIConfigResp struct {
config.Config
SyncNodeIds []int `json:"sync_node_ids" gorm:"serializer:json"`
SyncOverwrite bool `json:"sync_overwrite"`
}
func GetConfig(c *gin.Context) {
name := c.Param("name")
path := nginx.GetConfPath("/", name)
if !helper.IsUnderDirectory(path, nginx.GetConfPath()) {
c.JSON(http.StatusForbidden, gin.H{
"message": "path is not under the nginx conf path",
})
return
}
stat, err := os.Stat(path)
if err != nil {
api.ErrHandler(c, err)
return
}
content, err := os.ReadFile(path)
if err != nil {
api.ErrHandler(c, err)
return
}
q := query.Config
g := query.ChatGPTLog
chatgpt, err := g.Where(g.Name.Eq(path)).FirstOrCreate()
if err != nil {
api.ErrHandler(c, err)
return
}
if chatgpt.Content == nil {
chatgpt.Content = make([]openai.ChatCompletionMessage, 0)
}
cfg, err := q.Where(q.Filepath.Eq(path)).FirstOrInit()
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, APIConfigResp{
Config: config.Config{
Name: stat.Name(),
Content: string(content),
ChatGPTMessages: chatgpt.Content,
FilePath: path,
ModifiedAt: stat.ModTime(),
},
SyncNodeIds: cfg.SyncNodeIds,
SyncOverwrite: cfg.SyncOverwrite,
})
}

@ -0,0 +1,75 @@
package config
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/config"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/gin-gonic/gin"
"net/http"
"os"
"strings"
)
func GetConfigs(c *gin.Context) {
name := c.Query("name")
orderBy := c.Query("order_by")
sort := c.DefaultQuery("sort", "desc")
dir := c.DefaultQuery("dir", "/")
configFiles, err := os.ReadDir(nginx.GetConfPath(dir))
if err != nil {
api.ErrHandler(c, err)
return
}
configs := make([]config.Config, 0)
for i := range configFiles {
file := configFiles[i]
fileInfo, _ := file.Info()
if name != "" && !strings.Contains(file.Name(), name) {
continue
}
switch mode := fileInfo.Mode(); {
case mode.IsRegular(): // regular file, not a hidden file
if "." == file.Name()[0:1] {
continue
}
case mode&os.ModeSymlink != 0: // is a symbol
var targetPath string
targetPath, err = os.Readlink(nginx.GetConfPath(dir, file.Name()))
if err != nil {
logger.Error("Read Symlink Error", targetPath, err)
continue
}
var targetInfo os.FileInfo
targetInfo, err = os.Stat(targetPath)
if err != nil {
logger.Error("Stat Error", targetPath, err)
continue
}
// hide the file if it's target file is a directory
if targetInfo.IsDir() {
continue
}
}
configs = append(configs, config.Config{
Name: file.Name(),
ModifiedAt: fileInfo.ModTime(),
Size: fileInfo.Size(),
IsDir: fileInfo.IsDir(),
})
}
configs = config.Sort(orderBy, sort, configs)
c.JSON(http.StatusOK, gin.H{
"data": configs,
})
}

@ -0,0 +1,37 @@
package config
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/gin-gonic/gin"
"net/http"
"os"
)
func Mkdir(c *gin.Context) {
var json struct {
BasePath string `json:"base_path"`
FolderName string `json:"folder_name"`
}
if !api.BindAndValid(c, &json) {
return
}
fullPath := nginx.GetConfPath(json.BasePath, json.FolderName)
if !helper.IsUnderDirectory(fullPath, nginx.GetConfPath()) {
c.JSON(http.StatusForbidden, gin.H{
"message": "You are not allowed to create a folder " +
"outside of the nginx configuration directory",
})
return
}
err := os.Mkdir(fullPath, 0755)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,143 @@
package config
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/config"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"github.com/sashabaranov/go-openai"
"net/http"
"os"
"time"
)
type EditConfigJson struct {
Content string `json:"content" binding:"required"`
}
func EditConfig(c *gin.Context) {
name := c.Param("name")
var json struct {
Name string `json:"name" binding:"required"`
Filepath string `json:"filepath" binding:"required"`
NewFilepath string `json:"new_filepath" binding:"required"`
Content string `json:"content"`
SyncOverwrite bool `json:"sync_overwrite"`
SyncNodeIds []int `json:"sync_node_ids"`
}
if !api.BindAndValid(c, &json) {
return
}
path := json.Filepath
if !helper.IsUnderDirectory(path, nginx.GetConfPath()) {
c.JSON(http.StatusForbidden, gin.H{
"message": "filepath is not under the nginx conf path",
})
return
}
if !helper.IsUnderDirectory(json.NewFilepath, nginx.GetConfPath()) {
c.JSON(http.StatusForbidden, gin.H{
"message": "new filepath is not under the nginx conf path",
})
return
}
if !helper.FileExists(path) {
c.JSON(http.StatusNotFound, gin.H{
"message": "file not found",
})
return
}
content := json.Content
origContent, err := os.ReadFile(path)
if err != nil {
api.ErrHandler(c, err)
return
}
if content != "" && content != string(origContent) {
err = os.WriteFile(path, []byte(content), 0644)
if err != nil {
api.ErrHandler(c, err)
return
}
}
q := query.Config
cfg, err := q.Where(q.Filepath.Eq(json.Filepath)).FirstOrCreate()
if err != nil {
api.ErrHandler(c, err)
return
}
_, err = q.Where(q.Filepath.Eq(json.Filepath)).
Select(q.Name, q.Filepath, q.SyncNodeIds, q.SyncOverwrite).
Updates(&model.Config{
Name: json.Name,
Filepath: json.NewFilepath,
SyncNodeIds: json.SyncNodeIds,
SyncOverwrite: json.SyncOverwrite,
})
if err != nil {
api.ErrHandler(c, err)
return
}
g := query.ChatGPTLog
// handle rename
if path != json.NewFilepath {
if helper.FileExists(json.NewFilepath) {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "File exists",
})
return
}
err := os.Rename(json.Filepath, json.NewFilepath)
if err != nil {
api.ErrHandler(c, err)
return
}
// update ChatGPT record
_, _ = g.Where(g.Name.Eq(json.NewFilepath)).Delete()
_, _ = g.Where(g.Name.Eq(path)).Update(g.Name, json.NewFilepath)
}
err = config.SyncToRemoteServer(cfg, json.NewFilepath)
if err != nil {
api.ErrHandler(c, err)
return
}
output := nginx.Reload()
if nginx.GetLogLevel(output) >= nginx.Warn {
c.JSON(http.StatusInternalServerError, gin.H{
"message": output,
})
return
}
chatgpt, err := g.Where(g.Name.Eq(json.NewFilepath)).FirstOrCreate()
if err != nil {
api.ErrHandler(c, err)
return
}
if chatgpt.Content == nil {
chatgpt.Content = make([]openai.ChatCompletionMessage, 0)
}
c.JSON(http.StatusOK, config.Config{
Name: name,
Content: content,
ChatGPTMessages: chatgpt.Content,
FilePath: json.NewFilepath,
ModifiedAt: time.Now(),
})
}

@ -0,0 +1,97 @@
package config
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/config"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"net/http"
"os"
)
func Rename(c *gin.Context) {
var json struct {
BasePath string `json:"base_path"`
OrigName string `json:"orig_name"`
NewName string `json:"new_name"`
SyncNodeIds []int `json:"sync_node_ids" gorm:"serializer:json"`
}
if !api.BindAndValid(c, &json) {
return
}
logger.Debug(json)
if json.OrigName == json.NewName {
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
return
}
origFullPath := nginx.GetConfPath(json.BasePath, json.OrigName)
newFullPath := nginx.GetConfPath(json.BasePath, json.NewName)
if !helper.IsUnderDirectory(origFullPath, nginx.GetConfPath()) ||
!helper.IsUnderDirectory(newFullPath, nginx.GetConfPath()) {
c.JSON(http.StatusForbidden, gin.H{
"message": "you are not allowed to rename a file " +
"outside of the nginx config path",
})
return
}
stat, err := os.Stat(origFullPath)
if err != nil {
api.ErrHandler(c, err)
return
}
if helper.FileExists(newFullPath) {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "target file already exists",
})
return
}
err = os.Rename(origFullPath, newFullPath)
if err != nil {
api.ErrHandler(c, err)
return
}
// update ChatGPT records
g := query.ChatGPTLog
q := query.Config
cfg, err := q.Where(q.Filepath.Eq(origFullPath)).FirstOrInit()
if err != nil {
api.ErrHandler(c, err)
return
}
if !stat.IsDir() {
_, _ = g.Where(g.Name.Eq(newFullPath)).Delete()
_, _ = g.Where(g.Name.Eq(origFullPath)).Update(g.Name, newFullPath)
// for file, the sync policy for this file is used
json.SyncNodeIds = cfg.SyncNodeIds
} else {
// is directory, update all records under the directory
_, _ = g.Where(g.Name.Like(origFullPath+"%")).Update(g.Name, g.Name.Replace(origFullPath, newFullPath))
}
_, err = q.Where(q.Filepath.Eq(origFullPath)).Update(q.Filepath, newFullPath)
if err != nil {
api.ErrHandler(c, err)
return
}
if len(json.SyncNodeIds) > 0 {
err = config.SyncRenameOnRemoteServer(origFullPath, newFullPath, json.SyncNodeIds)
if err != nil {
api.ErrHandler(c, err)
return
}
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,21 @@
package config
import (
"github.com/0xJacky/Nginx-UI/internal/middleware"
"github.com/gin-gonic/gin"
)
func InitRouter(r *gin.RouterGroup) {
r.GET("config_base_path", GetBasePath)
r.GET("configs", GetConfigs)
r.GET("config/*name", GetConfig)
r.POST("config", AddConfig)
r.POST("config/*name", EditConfig)
o := r.Group("", middleware.RequireSecureSession())
{
o.POST("config_mkdir", Mkdir)
o.POST("config_rename", Rename)
}
}

@ -0,0 +1,47 @@
package nginx
import (
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/gin-gonic/gin"
"net/http"
"os"
)
func Reload(c *gin.Context) {
output := nginx.Reload()
c.JSON(http.StatusOK, gin.H{
"message": output,
"level": nginx.GetLogLevel(output),
})
}
func Test(c *gin.Context) {
output := nginx.TestConf()
c.JSON(http.StatusOK, gin.H{
"message": output,
"level": nginx.GetLogLevel(output),
})
}
func Restart(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
go nginx.Restart()
}
func Status(c *gin.Context) {
pidPath := nginx.GetPIDPath()
lastOutput := nginx.GetLastOutput()
running := true
if fileInfo, err := os.Stat(pidPath); err != nil || fileInfo.Size() == 0 { // fileInfo.Size() == 0 no process id
running = false
}
c.JSON(http.StatusOK, gin.H{
"running": running,
"message": lastOutput,
"level": nginx.GetLogLevel(lastOutput),
})
}

@ -0,0 +1,59 @@
package nginx
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/gin-gonic/gin"
"net/http"
)
func BuildNginxConfig(c *gin.Context) {
var ngxConf nginx.NgxConfig
if !api.BindAndValid(c, &ngxConf) {
return
}
content, err := ngxConf.BuildConfig()
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"content": content,
})
}
func TokenizeNginxConfig(c *gin.Context) {
var json struct {
Content string `json:"content" binding:"required"`
}
if !api.BindAndValid(c, &json) {
return
}
ngxConfig, err := nginx.ParseNgxConfigByContent(json.Content)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, ngxConfig)
}
func FormatNginxConfig(c *gin.Context) {
var json struct {
Content string `json:"content" binding:"required"`
}
if !api.BindAndValid(c, &json) {
return
}
content, err := nginx.FmtCode(json.Content)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"content": content,
})
}

@ -1,19 +1,19 @@
package api
package nginx
import (
"encoding/json"
"github.com/0xJacky/Nginx-UI/server/pkg/helper"
"github.com/0xJacky/Nginx-UI/server/pkg/nginx"
"github.com/0xJacky/Nginx-UI/server/settings"
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"github.com/hpcloud/tail"
"github.com/pkg/errors"
"github.com/spf13/cast"
"io"
"log"
"net/http"
"os"
"strings"
)
const (
@ -39,30 +39,36 @@ func GetNginxLogPage(c *gin.Context) {
}
var control controlStruct
if !BindAndValid(c, &control) {
if !api.BindAndValid(c, &control) {
return
}
logPath, err := getLogPath(&control)
if err != nil {
log.Println("error GetNginxLogPage", err)
logger.Error(err)
return
}
f, err := os.Open(logPath)
logFileStat, err := os.Stat(logPath)
if err != nil {
c.JSON(http.StatusOK, nginxLogPageResp{})
log.Println("error GetNginxLogPage open file", err)
logger.Error(err)
return
}
logFileStat, err := os.Stat(logPath)
if !logFileStat.Mode().IsRegular() {
c.JSON(http.StatusOK, nginxLogPageResp{})
logger.Error("log file is not regular file:", logPath)
return
}
f, err := os.Open(logPath)
if err != nil {
c.JSON(http.StatusOK, nginxLogPageResp{})
log.Println("error GetNginxLogPage stat", err)
logger.Error(err)
return
}
@ -85,7 +91,7 @@ func GetNginxLogPage(c *gin.Context) {
_, err = f.Seek(offset, io.SeekStart)
if err != nil && err != io.EOF {
c.JSON(http.StatusOK, nginxLogPageResp{})
log.Println("error GetNginxLogPage seek", err)
logger.Error(err)
return
}
@ -93,7 +99,7 @@ func GetNginxLogPage(c *gin.Context) {
if err != nil && err != io.EOF {
c.JSON(http.StatusOK, nginxLogPageResp{})
log.Println("error GetNginxLogPage read buf", err)
logger.Error(err)
return
}
@ -138,23 +144,32 @@ func getLogPath(control *controlStruct) (logPath string, err error) {
return
}
logPath = directive.Params
// fix: access_log /var/log/test.log main;
p := strings.Split(directive.Params, " ")
if len(p) > 0 {
logPath = p[0]
}
case "error":
if settings.NginxLogSettings.ErrorLogPath == "" {
path := nginx.GetErrorLogPath()
if path == "" {
err = errors.New("settings.NginxLogSettings.ErrorLogPath is empty," +
" see https://github.com/0xJacky/nginx-ui/wiki/Nginx-Log-Configuration for more information")
" refer to https://nginxui.com/guide/config-nginx.html for more information")
return
}
logPath = settings.NginxLogSettings.ErrorLogPath
logPath = path
default:
if settings.NginxLogSettings.AccessLogPath == "" {
path := nginx.GetAccessLogPath()
if path == "" {
err = errors.New("settings.NginxLogSettings.AccessLogPath is empty," +
" see https://github.com/0xJacky/nginx-ui/wiki/Nginx-Log-Configuration for more information")
" refer to https://nginxui.com/guide/config-nginx.html for more information")
return
}
logPath = settings.NginxLogSettings.AccessLogPath
logPath = path
}
return
@ -163,7 +178,7 @@ func getLogPath(control *controlStruct) (logPath string, err error) {
func tailNginxLog(ws *websocket.Conn, controlChan chan controlStruct, errChan chan error) {
defer func() {
if err := recover(); err != nil {
log.Println("tailNginxLog recovery", err)
logger.Error(err)
return
}
}()
@ -183,8 +198,16 @@ func tailNginxLog(ws *websocket.Conn, controlChan chan controlStruct, errChan ch
Whence: io.SeekEnd,
}
if !helper.FileExists(logPath) {
errChan <- errors.New("error log path not exists")
stat, err := os.Stat(logPath)
if os.IsNotExist(err) {
errChan <- errors.New("[error] log path not exists " + logPath)
return
}
if !stat.Mode().IsRegular() {
errChan <- errors.New("[error] " + logPath + " is not a regular file. " +
"If you are using nginx-ui in docker container, please refer to " +
"https://nginxui.com/zh_CN/guide/config-nginx-log.html for more information.")
return
}
@ -226,7 +249,7 @@ func tailNginxLog(ws *websocket.Conn, controlChan chan controlStruct, errChan ch
func handleLogControl(ws *websocket.Conn, controlChan chan controlStruct, errChan chan error) {
defer func() {
if err := recover(); err != nil {
log.Println("handleLogControl recovery", err)
logger.Error(err)
return
}
}()
@ -253,7 +276,7 @@ func handleLogControl(ws *websocket.Conn, controlChan chan controlStruct, errCha
}
}
func NginxLog(c *gin.Context) {
func Log(c *gin.Context) {
var upGrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
@ -262,7 +285,7 @@ func NginxLog(c *gin.Context) {
// upgrade http to websocket
ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
log.Println("[Error] NginxLog Upgrade", err)
logger.Error(err)
return
}
@ -275,7 +298,7 @@ func NginxLog(c *gin.Context) {
go handleLogControl(ws, controlChan, errChan)
if err = <-errChan; err != nil {
log.Println(err)
logger.Error(err)
_ = ws.WriteMessage(websocket.TextMessage, []byte(err.Error()))
return
}

@ -0,0 +1,18 @@
package nginx
import "github.com/gin-gonic/gin"
func InitRouter(r *gin.RouterGroup) {
r.POST("ngx/build_config", BuildNginxConfig)
r.POST("ngx/tokenize_config", TokenizeNginxConfig)
r.POST("ngx/format_code", FormatNginxConfig)
r.POST("nginx/reload", Reload)
r.POST("nginx/restart", Restart)
r.POST("nginx/test", Test)
r.GET("nginx/status", Status)
r.POST("nginx_log", GetNginxLogPage)
}
func InitNginxLogRouter(r *gin.RouterGroup) {
r.GET("nginx_log", Log)
}

@ -0,0 +1,56 @@
package notification
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/cosy"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"github.com/spf13/cast"
"net/http"
)
func Get(c *gin.Context) {
n := query.Notification
id := cast.ToInt(c.Param("id"))
data, err := n.FirstByID(id)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, data)
}
func GetList(c *gin.Context) {
cosy.Core[model.Notification](c).PagingList()
}
func Destroy(c *gin.Context) {
cosy.Core[model.Notification](c).Destroy()
}
func DestroyAll(c *gin.Context) {
db := model.UseDB()
// remove all records
err := db.Exec("DELETE FROM notifications").Error
if err != nil {
api.ErrHandler(c, err)
return
}
// reset auto increment
err = db.Exec("UPDATE sqlite_sequence SET seq = 0 WHERE name = 'notifications';").Error
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,10 @@
package notification
import "github.com/gin-gonic/gin"
func InitRouter(r *gin.RouterGroup) {
r.GET("notifications", GetList)
r.GET("notification/:id", Get)
r.DELETE("notification/:id", Destroy)
r.DELETE("notifications", DestroyAll)
}

@ -1,28 +1,33 @@
package api
package openai
import (
"context"
"crypto/tls"
"fmt"
"github.com/0xJacky/Nginx-UI/server/model"
"github.com/0xJacky/Nginx-UI/server/query"
"github.com/0xJacky/Nginx-UI/server/settings"
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/chatbot"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"github.com/sashabaranov/go-openai"
"io"
"net/http"
"net/url"
"os"
)
const ChatGPTInitPrompt = "You are a assistant who can help users write and optimise the configurations of Nginx, the first user message contains the content of the configuration file which is currently opened by the user and the current language code(CLC). You suppose to use the language corresponding to the CLC to give the first reply. Later the language environment depends on the user message. The first reply should involve the key information of the file and ask user what can you help them."
const ChatGPTInitPrompt = `You are a assistant who can help users write and optimise the configurations of Nginx,
the first user message contains the content of the configuration file which is currently opened by the user and
the current language code(CLC). You suppose to use the language corresponding to the CLC to give the first reply.
Later the language environment depends on the user message.
The first reply should involve the key information of the file and ask user what can you help them.`
func MakeChatCompletionRequest(c *gin.Context) {
var json struct {
Filepath string `json:"filepath"`
Messages []openai.ChatCompletionMessage `json:"messages"`
}
if !BindAndValid(c, &json) {
if !api.BindAndValid(c, &json) {
return
}
@ -32,24 +37,19 @@ func MakeChatCompletionRequest(c *gin.Context) {
Content: ChatGPTInitPrompt,
},
}
messages = append(messages, json.Messages...)
// sse server
c.Writer.Header().Set("Content-Type", "text/event-stream")
if json.Filepath != "" {
messages = chatbot.ChatCompletionWithContext(json.Filepath, messages)
}
// SSE server
c.Writer.Header().Set("Content-Type", "text/event-stream; charset=utf-8")
c.Writer.Header().Set("Cache-Control", "no-cache")
c.Writer.Header().Set("Connection", "keep-alive")
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
if settings.OpenAISettings.Token == "" {
c.Stream(func(w io.Writer) bool {
c.SSEvent("message", gin.H{
"type": "error",
"content": "[Error] OpenAI token is empty",
})
return false
})
return
}
config := openai.DefaultConfig(settings.OpenAISettings.Token)
if settings.OpenAISettings.Proxy != "" {
@ -65,7 +65,8 @@ func MakeChatCompletionRequest(c *gin.Context) {
return
}
transport := &http.Transport{
Proxy: http.ProxyURL(proxyUrl),
Proxy: http.ProxyURL(proxyUrl),
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
}
config.HTTPClient = &http.Client{
Transport: transport,
@ -99,23 +100,20 @@ func MakeChatCompletionRequest(c *gin.Context) {
defer stream.Close()
msgChan := make(chan string)
go func() {
defer close(msgChan)
for {
response, err := stream.Recv()
if errors.Is(err, io.EOF) {
close(msgChan)
fmt.Println()
return
}
if err != nil {
fmt.Printf("Stream error: %v\n", err)
close(msgChan)
return
}
message := fmt.Sprintf("%s", response.Choices[0].Delta.Content)
fmt.Printf("%s", message)
_ = os.Stdout.Sync()
msgChan <- message
}
@ -132,37 +130,3 @@ func MakeChatCompletionRequest(c *gin.Context) {
return false
})
}
func StoreChatGPTRecord(c *gin.Context) {
var json struct {
FileName string `json:"file_name"`
Messages []openai.ChatCompletionMessage `json:"messages"`
}
if !BindAndValid(c, &json) {
return
}
name := json.FileName
g := query.ChatGPTLog
_, err := g.Where(g.Name.Eq(name)).FirstOrCreate()
if err != nil {
ErrHandler(c, err)
return
}
_, err = g.Where(g.Name.Eq(name)).Updates(&model.ChatGPTLog{
Name: name,
Content: json.Messages,
})
if err != nil {
ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,9 @@
package openai
import "github.com/gin-gonic/gin"
func InitRouter(r *gin.RouterGroup) {
// ChatGPT
r.POST("chatgpt", MakeChatCompletionRequest)
r.POST("chatgpt_record", StoreChatGPTRecord)
}

@ -0,0 +1,44 @@
package openai
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"github.com/sashabaranov/go-openai"
"net/http"
)
func StoreChatGPTRecord(c *gin.Context) {
var json struct {
FileName string `json:"file_name"`
Messages []openai.ChatCompletionMessage `json:"messages"`
}
if !api.BindAndValid(c, &json) {
return
}
name := json.FileName
g := query.ChatGPTLog
_, err := g.Where(g.Name.Eq(name)).FirstOrCreate()
if err != nil {
api.ErrHandler(c, err)
return
}
_, err = g.Where(g.Name.Eq(name)).Updates(&model.ChatGPTLog{
Name: name,
Content: json.Messages,
})
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,45 @@
package settings
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/query"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"net/http"
"time"
)
func GetBanLoginIP(c *gin.Context) {
b := query.BanIP
// clear expired banned IPs
_, _ = b.Where(b.ExpiredAt.Lte(time.Now().Unix())).Delete()
banIps, err := b.Where(
b.ExpiredAt.Gte(time.Now().Unix()),
b.Attempts.Gte(settings.AuthSettings.MaxAttempts)).Find()
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, banIps)
}
func RemoveBannedIP(c *gin.Context) {
var json struct {
IP string `json:"ip"`
}
if !api.BindAndValid(c, &json) {
return
}
b := query.BanIP
_, err := b.Where(b.IP.Eq(json.IP)).Delete()
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusNoContent, nil)
}

@ -0,0 +1,15 @@
package settings
import (
"github.com/0xJacky/Nginx-UI/internal/middleware"
"github.com/gin-gonic/gin"
)
func InitRouter(r *gin.RouterGroup) {
r.GET("settings/server/name", GetServerName)
r.GET("settings", GetSettings)
r.POST("settings", middleware.RequireSecureSession(), SaveSettings)
r.GET("settings/auth/banned_ips", GetBanLoginIP)
r.DELETE("settings/auth/banned_ip", RemoveBannedIP)
}

@ -0,0 +1,58 @@
package settings
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/cron"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"net/http"
)
func GetServerName(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"name": settings.ServerSettings.Name,
})
}
func GetSettings(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"server": settings.ServerSettings,
"nginx": settings.NginxSettings,
"openai": settings.OpenAISettings,
"logrotate": settings.LogrotateSettings,
"auth": settings.AuthSettings,
})
}
func SaveSettings(c *gin.Context) {
var json struct {
Server settings.Server `json:"server"`
Nginx settings.Nginx `json:"nginx"`
Openai settings.OpenAI `json:"openai"`
Logrotate settings.Logrotate `json:"logrotate"`
Auth settings.Auth `json:"auth"`
}
if !api.BindAndValid(c, &json) {
return
}
if settings.LogrotateSettings.Enabled != json.Logrotate.Enabled ||
settings.LogrotateSettings.Interval != json.Logrotate.Interval {
go cron.RestartLogrotate()
}
settings.ProtectedFill(&settings.ServerSettings, &json.Server)
settings.ProtectedFill(&settings.NginxSettings, &json.Nginx)
settings.ProtectedFill(&settings.OpenAISettings, &json.Openai)
settings.ProtectedFill(&settings.LogrotateSettings, &json.Logrotate)
settings.ProtectedFill(&settings.AuthSettings, &json.Auth)
err := settings.Save()
if err != nil {
api.ErrHandler(c, err)
return
}
GetSettings(c)
}

@ -0,0 +1,42 @@
package sites
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"net/http"
)
func DomainEditByAdvancedMode(c *gin.Context) {
var json struct {
Advanced bool `json:"advanced"`
}
if !api.BindAndValid(c, &json) {
return
}
name := c.Param("name")
path := nginx.GetConfPath("sites-available", name)
s := query.Site
_, err := s.Where(s.Path.Eq(path)).FirstOrCreate()
if err != nil {
api.ErrHandler(c, err)
return
}
_, err = s.Where(s.Path.Eq(path)).Update(s.Advanced, json.Advanced)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,67 @@
package sites
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/model"
"github.com/gin-gonic/gin"
"github.com/go-acme/lego/v4/certcrypto"
"net/http"
)
func AddDomainToAutoCert(c *gin.Context) {
name := c.Param("name")
var json struct {
DnsCredentialID int `json:"dns_credential_id"`
ChallengeMethod string `json:"challenge_method"`
Domains []string `json:"domains"`
KeyType certcrypto.KeyType `json:"key_type"`
}
if !api.BindAndValid(c, &json) {
return
}
certModel, err := model.FirstOrCreateCert(name, helper.GetKeyType(json.KeyType))
if err != nil {
api.ErrHandler(c, err)
return
}
err = certModel.Updates(&model.Cert{
Name: name,
Domains: json.Domains,
AutoCert: model.AutoCertEnabled,
DnsCredentialID: json.DnsCredentialID,
ChallengeMethod: json.ChallengeMethod,
})
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, certModel)
}
func RemoveDomainFromAutoCert(c *gin.Context) {
name := c.Param("name")
certModel, err := model.FirstCert(name)
if err != nil {
api.ErrHandler(c, err)
return
}
err = certModel.Updates(&model.Cert{
AutoCert: model.AutoCertDisabled,
})
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, nil)
}

@ -1,18 +1,19 @@
package api
package sites
import (
"github.com/0xJacky/Nginx-UI/server/model"
"github.com/0xJacky/Nginx-UI/server/pkg/cert"
"github.com/0xJacky/Nginx-UI/server/pkg/config_list"
"github.com/0xJacky/Nginx-UI/server/pkg/helper"
"github.com/0xJacky/Nginx-UI/server/pkg/nginx"
"github.com/0xJacky/Nginx-UI/server/query"
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/cert"
"github.com/0xJacky/Nginx-UI/internal/config"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"log"
"github.com/sashabaranov/go-openai"
"net/http"
"os"
"strings"
"time"
)
func GetDomains(c *gin.Context) {
@ -20,23 +21,15 @@ func GetDomains(c *gin.Context) {
orderBy := c.Query("order_by")
sort := c.DefaultQuery("sort", "desc")
mySort := map[string]string{
"enabled": "bool",
"name": "string",
"modify": "time",
}
configFiles, err := os.ReadDir(nginx.GetConfPath("sites-available"))
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
enabledConfig, err := os.ReadDir(nginx.GetConfPath("sites-enabled"))
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
@ -45,7 +38,7 @@ func GetDomains(c *gin.Context) {
enabledConfigMap[enabledConfig[i].Name()] = true
}
var configs []gin.H
var configs []config.Config
for i := range configFiles {
file := configFiles[i]
@ -54,32 +47,25 @@ func GetDomains(c *gin.Context) {
if name != "" && !strings.Contains(file.Name(), name) {
continue
}
configs = append(configs, gin.H{
"name": file.Name(),
"size": fileInfo.Size(),
"modify": fileInfo.ModTime(),
"enabled": enabledConfigMap[file.Name()],
configs = append(configs, config.Config{
Name: file.Name(),
ModifiedAt: fileInfo.ModTime(),
Size: fileInfo.Size(),
IsDir: fileInfo.IsDir(),
Enabled: enabledConfigMap[file.Name()],
})
}
}
configs = config_list.Sort(orderBy, sort, mySort[orderBy], configs)
configs = config.Sort(orderBy, sort, configs)
c.JSON(http.StatusOK, gin.H{
"data": configs,
})
}
type CertificateInfo struct {
SubjectName string `json:"subject_name"`
IssuerName string `json:"issuer_name"`
NotAfter time.Time `json:"not_after"`
NotBefore time.Time `json:"not_before"`
}
func GetDomain(c *gin.Context) {
rewriteName, ok := c.Get("rewriteConfigFileName")
name := c.Param("name")
// for modify filename
@ -88,6 +74,13 @@ func GetDomain(c *gin.Context) {
}
path := nginx.GetConfPath("sites-available", name)
file, err := os.Stat(path)
if os.IsNotExist(err) {
c.JSON(http.StatusNotFound, gin.H{
"message": "file not found",
})
return
}
enabled := true
if _, err := os.Stat(nginx.GetConfPath("sites-enabled", name)); os.IsNotExist(err) {
@ -96,87 +89,79 @@ func GetDomain(c *gin.Context) {
g := query.ChatGPTLog
chatgpt, err := g.Where(g.Name.Eq(path)).FirstOrCreate()
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
if chatgpt.Content == nil {
chatgpt.Content = make([]openai.ChatCompletionMessage, 0)
}
s := query.Site
site, err := s.Where(s.Path.Eq(path)).FirstOrInit()
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
certModel, _ := model.FirstCert(name)
certModel, err := model.FirstCert(name)
if err != nil {
logger.Warn(err)
}
if site.Advanced {
origContent, err := os.ReadFile(path)
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"advanced": site.Advanced,
"enabled": enabled,
"name": name,
"config": string(origContent),
"auto_cert": certModel.AutoCert == model.AutoCertEnabled,
"chatgpt_messages": chatgpt.Content,
c.JSON(http.StatusOK, Site{
ModifiedAt: file.ModTime(),
Advanced: site.Advanced,
Enabled: enabled,
Name: name,
Config: string(origContent),
AutoCert: certModel.AutoCert == model.AutoCertEnabled,
ChatGPTMessages: chatgpt.Content,
Filepath: path,
})
return
}
c.Set("maybe_error", "nginx_config_syntax_error")
config, err := nginx.ParseNgxConfig(path)
nginxConfig, err := nginx.ParseNgxConfig(path)
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
c.Set("maybe_error", "")
certInfoMap := make(map[int]CertificateInfo)
for serverIdx, server := range config.Servers {
certInfoMap := make(map[int][]*cert.Info)
for serverIdx, server := range nginxConfig.Servers {
for _, directive := range server.Directives {
if directive.Directive == "ssl_certificate" {
pubKey, err := cert.GetCertInfo(directive.Params)
if err != nil {
log.Println("Failed to get certificate information", err)
break
}
certInfoMap[serverIdx] = CertificateInfo{
SubjectName: pubKey.Subject.CommonName,
IssuerName: pubKey.Issuer.CommonName,
NotAfter: pubKey.NotAfter,
NotBefore: pubKey.NotBefore,
logger.Error("Failed to get certificate information", err)
continue
}
break
certInfoMap[serverIdx] = append(certInfoMap[serverIdx], pubKey)
}
}
}
c.Set("maybe_error", "nginx_config_syntax_error")
c.JSON(http.StatusOK, gin.H{
"advanced": site.Advanced,
"enabled": enabled,
"name": name,
"config": config.FmtCode(),
"tokenized": config,
"auto_cert": certModel.AutoCert == model.AutoCertEnabled,
"cert_info": certInfoMap,
"chatgpt_messages": chatgpt.Content,
c.JSON(http.StatusOK, Site{
ModifiedAt: file.ModTime(),
Advanced: site.Advanced,
Enabled: enabled,
Name: name,
Config: nginxConfig.FmtCode(),
Tokenized: nginxConfig,
AutoCert: certModel.AutoCert == model.AutoCertEnabled,
CertInfo: certInfoMap,
ChatGPTMessages: chatgpt.Content,
Filepath: path,
})
}
func SaveDomain(c *gin.Context) {
@ -195,7 +180,7 @@ func SaveDomain(c *gin.Context) {
Overwrite bool `json:"overwrite"`
}
if !BindAndValid(c, &json) {
if !api.BindAndValid(c, &json) {
return
}
@ -210,7 +195,7 @@ func SaveDomain(c *gin.Context) {
err := os.WriteFile(path, []byte(json.Content), 0644)
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
enabledConfigFilePath := nginx.GetConfPath("sites-enabled", name)
@ -227,21 +212,21 @@ func SaveDomain(c *gin.Context) {
})
return
}
// recreate soft link
// recreate a soft link
if helper.FileExists(enabledConfigFilePath) {
_ = os.Remove(enabledConfigFilePath)
enabledConfigFilePath = nginx.GetConfPath("sites-enabled", json.Name)
err = os.Symlink(newPath, enabledConfigFilePath)
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
}
err = os.Rename(path, newPath)
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
@ -253,17 +238,17 @@ func SaveDomain(c *gin.Context) {
if helper.FileExists(enabledConfigFilePath) {
// Test nginx configuration
output := nginx.TestConf()
if nginx.GetLogLevel(output) >= nginx.Warn {
if nginx.GetLogLevel(output) > nginx.Warn {
c.JSON(http.StatusInternalServerError, gin.H{
"message": output,
"error": "nginx_config_syntax_error",
})
return
}
output = nginx.Reload()
if nginx.GetLogLevel(output) >= nginx.Warn {
if nginx.GetLogLevel(output) > nginx.Warn {
c.JSON(http.StatusInternalServerError, gin.H{
"message": output,
})
@ -281,7 +266,7 @@ func EnableDomain(c *gin.Context) {
_, err := os.Stat(configFilePath)
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
@ -289,15 +274,14 @@ func EnableDomain(c *gin.Context) {
err = os.Symlink(configFilePath, enabledConfigFilePath)
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
}
// Test nginx config, if not pass then disable the site.
// Test nginx config, if not pass, then disable the site.
output := nginx.TestConf()
if nginx.GetLogLevel(output) >= nginx.Warn {
if nginx.GetLogLevel(output) > nginx.Warn {
_ = os.Remove(enabledConfigFilePath)
c.JSON(http.StatusInternalServerError, gin.H{
"message": output,
@ -307,7 +291,7 @@ func EnableDomain(c *gin.Context) {
output = nginx.Reload()
if nginx.GetLogLevel(output) >= nginx.Warn {
if nginx.GetLogLevel(output) > nginx.Warn {
c.JSON(http.StatusInternalServerError, gin.H{
"message": output,
})
@ -321,18 +305,15 @@ func EnableDomain(c *gin.Context) {
func DisableDomain(c *gin.Context) {
enabledConfigFilePath := nginx.GetConfPath("sites-enabled", c.Param("name"))
_, err := os.Stat(enabledConfigFilePath)
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
err = os.Remove(enabledConfigFilePath)
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
@ -340,13 +321,12 @@ func DisableDomain(c *gin.Context) {
certModel := model.Cert{Filename: c.Param("name")}
err = certModel.Remove()
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
output := nginx.Reload()
if nginx.GetLogLevel(output) >= nginx.Warn {
if nginx.GetLogLevel(output) > nginx.Warn {
c.JSON(http.StatusInternalServerError, gin.H{
"message": output,
})
@ -363,7 +343,6 @@ func DeleteDomain(c *gin.Context) {
name := c.Param("name")
availablePath := nginx.GetConfPath("sites-available", name)
enabledPath := nginx.GetConfPath("sites-enabled", name)
if _, err = os.Stat(availablePath); os.IsNotExist(err) {
c.JSON(http.StatusNotFound, gin.H{
"message": "site not found",
@ -382,132 +361,12 @@ func DeleteDomain(c *gin.Context) {
_ = certModel.Remove()
err = os.Remove(availablePath)
if err != nil {
ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}
func AddDomainToAutoCert(c *gin.Context) {
name := c.Param("name")
var json struct {
Domains []string `json:"domains"`
}
if !BindAndValid(c, &json) {
return
}
certModel, err := model.FirstOrCreateCert(name)
if err != nil {
ErrHandler(c, err)
return
}
err = certModel.Updates(&model.Cert{
Name: name,
Domains: json.Domains,
AutoCert: model.AutoCertEnabled,
})
if err != nil {
ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, certModel)
}
func RemoveDomainFromAutoCert(c *gin.Context) {
name := c.Param("name")
certModel, err := model.FirstCert(name)
if err != nil {
ErrHandler(c, err)
return
}
err = certModel.Updates(&model.Cert{
AutoCert: model.AutoCertDisabled,
})
if err != nil {
ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, nil)
}
func DuplicateSite(c *gin.Context) {
name := c.Param("name")
var json struct {
Name string `json:"name" binding:"required"`
}
if !BindAndValid(c, &json) {
return
}
src := nginx.GetConfPath("sites-available", name)
dst := nginx.GetConfPath("sites-available", json.Name)
if helper.FileExists(dst) {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "File exists",
})
return
}
_, err := helper.CopyFile(src, dst)
if err != nil {
ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"dst": dst,
})
}
func DomainEditByAdvancedMode(c *gin.Context) {
var json struct {
Advanced bool `json:"advanced"`
}
if !BindAndValid(c, &json) {
return
}
name := c.Param("name")
path := nginx.GetConfPath("sites-available", name)
s := query.Site
_, err := s.Where(s.Path.Eq(path)).FirstOrCreate()
if err != nil {
ErrHandler(c, err)
return
}
_, err = s.Where(s.Path.Eq(path)).Update(s.Advanced, json.Advanced)
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,44 @@
package sites
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/gin-gonic/gin"
"net/http"
)
func DuplicateSite(c *gin.Context) {
// Source name
name := c.Param("name")
// Destination name
var json struct {
Name string `json:"name" binding:"required"`
}
if !api.BindAndValid(c, &json) {
return
}
src := nginx.GetConfPath("sites-available", name)
dst := nginx.GetConfPath("sites-available", json.Name)
if helper.FileExists(dst) {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "File exists",
})
return
}
_, err := helper.CopyFile(src, dst)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"dst": dst,
})
}

@ -0,0 +1,16 @@
package sites
import "github.com/gin-gonic/gin"
func InitRouter(r *gin.RouterGroup) {
r.GET("domains", GetDomains)
r.GET("domain/:name", GetDomain)
r.POST("domain/:name", SaveDomain)
r.POST("domain/:name/enable", EnableDomain)
r.POST("domain/:name/disable", DisableDomain)
r.POST("domain/:name/advance", DomainEditByAdvancedMode)
r.DELETE("domain/:name", DeleteDomain)
r.POST("domain/:name/duplicate", DuplicateSite)
r.POST("auto_cert/:name", AddDomainToAutoCert)
r.DELETE("auto_cert/:name", RemoveDomainFromAutoCert)
}

@ -0,0 +1,21 @@
package sites
import (
"github.com/0xJacky/Nginx-UI/internal/cert"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/sashabaranov/go-openai"
"time"
)
type Site struct {
ModifiedAt time.Time `json:"modified_at"`
Advanced bool `json:"advanced"`
Enabled bool `json:"enabled"`
Name string `json:"name"`
Config string `json:"config"`
AutoCert bool `json:"auto_cert"`
ChatGPTMessages []openai.ChatCompletionMessage `json:"chatgpt_messages,omitempty"`
Tokenized *nginx.NgxConfig `json:"tokenized,omitempty"`
CertInfo map[int][]*cert.Info `json:"cert_info,omitempty"`
Filepath string `json:"filepath"`
}

@ -0,0 +1,42 @@
package streams
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"net/http"
)
func AdvancedEdit(c *gin.Context) {
var json struct {
Advanced bool `json:"advanced"`
}
if !api.BindAndValid(c, &json) {
return
}
name := c.Param("name")
path := nginx.GetConfPath("streams-available", name)
s := query.Site
_, err := s.Where(s.Path.Eq(path)).FirstOrCreate()
if err != nil {
api.ErrHandler(c, err)
return
}
_, err = s.Where(s.Path.Eq(path)).Update(s.Advanced, json.Advanced)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,44 @@
package streams
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/gin-gonic/gin"
"net/http"
)
func Duplicate(c *gin.Context) {
// Source name
name := c.Param("name")
// Destination name
var json struct {
Name string `json:"name" binding:"required"`
}
if !api.BindAndValid(c, &json) {
return
}
src := nginx.GetConfPath("streams-available", name)
dst := nginx.GetConfPath("streams-available", json.Name)
if helper.FileExists(dst) {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "File exists",
})
return
}
_, err := helper.CopyFile(src, dst)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"dst": dst,
})
}

@ -0,0 +1,14 @@
package streams
import "github.com/gin-gonic/gin"
func InitRouter(r *gin.RouterGroup) {
r.GET("streams", GetStreams)
r.GET("stream/:name", GetStream)
r.POST("stream/:name", SaveStream)
r.POST("stream/:name/enable", EnableStream)
r.POST("stream/:name/disable", DisableStream)
r.POST("stream/:name/advance", AdvancedEdit)
r.DELETE("stream/:name", DeleteStream)
r.POST("stream/:name/duplicate", Duplicate)
}

@ -0,0 +1,359 @@
package streams
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/config"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"github.com/sashabaranov/go-openai"
"net/http"
"os"
"strings"
"time"
)
type Stream struct {
ModifiedAt time.Time `json:"modified_at"`
Advanced bool `json:"advanced"`
Enabled bool `json:"enabled"`
Name string `json:"name"`
Config string `json:"config"`
ChatGPTMessages []openai.ChatCompletionMessage `json:"chatgpt_messages,omitempty"`
Tokenized *nginx.NgxConfig `json:"tokenized,omitempty"`
Filepath string `json:"filepath"`
}
func GetStreams(c *gin.Context) {
name := c.Query("name")
orderBy := c.Query("order_by")
sort := c.DefaultQuery("sort", "desc")
configFiles, err := os.ReadDir(nginx.GetConfPath("streams-available"))
if err != nil {
api.ErrHandler(c, err)
return
}
enabledConfig, err := os.ReadDir(nginx.GetConfPath("streams-enabled"))
if err != nil {
api.ErrHandler(c, err)
return
}
enabledConfigMap := make(map[string]bool)
for i := range enabledConfig {
enabledConfigMap[enabledConfig[i].Name()] = true
}
var configs []config.Config
for i := range configFiles {
file := configFiles[i]
fileInfo, _ := file.Info()
if !file.IsDir() {
if name != "" && !strings.Contains(file.Name(), name) {
continue
}
configs = append(configs, config.Config{
Name: file.Name(),
ModifiedAt: fileInfo.ModTime(),
Size: fileInfo.Size(),
IsDir: fileInfo.IsDir(),
Enabled: enabledConfigMap[file.Name()],
})
}
}
configs = config.Sort(orderBy, sort, configs)
c.JSON(http.StatusOK, gin.H{
"data": configs,
})
}
func GetStream(c *gin.Context) {
rewriteName, ok := c.Get("rewriteConfigFileName")
name := c.Param("name")
// for modify filename
if ok {
name = rewriteName.(string)
}
path := nginx.GetConfPath("streams-available", name)
file, err := os.Stat(path)
if os.IsNotExist(err) {
c.JSON(http.StatusNotFound, gin.H{
"message": "file not found",
})
return
}
enabled := true
if _, err := os.Stat(nginx.GetConfPath("streams-enabled", name)); os.IsNotExist(err) {
enabled = false
}
g := query.ChatGPTLog
chatgpt, err := g.Where(g.Name.Eq(path)).FirstOrCreate()
if err != nil {
api.ErrHandler(c, err)
return
}
if chatgpt.Content == nil {
chatgpt.Content = make([]openai.ChatCompletionMessage, 0)
}
s := query.Stream
stream, err := s.Where(s.Path.Eq(path)).FirstOrInit()
if err != nil {
api.ErrHandler(c, err)
return
}
if stream.Advanced {
origContent, err := os.ReadFile(path)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, Stream{
ModifiedAt: file.ModTime(),
Advanced: stream.Advanced,
Enabled: enabled,
Name: name,
Config: string(origContent),
ChatGPTMessages: chatgpt.Content,
Filepath: path,
})
return
}
nginxConfig, err := nginx.ParseNgxConfig(path)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, Stream{
ModifiedAt: file.ModTime(),
Advanced: stream.Advanced,
Enabled: enabled,
Name: name,
Config: nginxConfig.FmtCode(),
Tokenized: nginxConfig,
ChatGPTMessages: chatgpt.Content,
Filepath: path,
})
}
func SaveStream(c *gin.Context) {
name := c.Param("name")
if name == "" {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "param name is empty",
})
return
}
var json struct {
Name string `json:"name" binding:"required"`
Content string `json:"content" binding:"required"`
Overwrite bool `json:"overwrite"`
}
if !api.BindAndValid(c, &json) {
return
}
path := nginx.GetConfPath("streams-available", name)
if !json.Overwrite && helper.FileExists(path) {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "File exists",
})
return
}
err := os.WriteFile(path, []byte(json.Content), 0644)
if err != nil {
api.ErrHandler(c, err)
return
}
enabledConfigFilePath := nginx.GetConfPath("streams-enabled", name)
// rename the config file if needed
if name != json.Name {
newPath := nginx.GetConfPath("streams-available", json.Name)
s := query.Stream
_, err = s.Where(s.Path.Eq(path)).Update(s.Path, newPath)
// check if dst file exists, do not rename
if helper.FileExists(newPath) {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "File exists",
})
return
}
// recreate a soft link
if helper.FileExists(enabledConfigFilePath) {
_ = os.Remove(enabledConfigFilePath)
enabledConfigFilePath = nginx.GetConfPath("streams-enabled", json.Name)
err = os.Symlink(newPath, enabledConfigFilePath)
if err != nil {
api.ErrHandler(c, err)
return
}
}
err = os.Rename(path, newPath)
if err != nil {
api.ErrHandler(c, err)
return
}
name = json.Name
c.Set("rewriteConfigFileName", name)
}
enabledConfigFilePath = nginx.GetConfPath("streams-enabled", name)
if helper.FileExists(enabledConfigFilePath) {
// Test nginx configuration
output := nginx.TestConf()
if nginx.GetLogLevel(output) > nginx.Warn {
c.JSON(http.StatusInternalServerError, gin.H{
"message": output,
})
return
}
output = nginx.Reload()
if nginx.GetLogLevel(output) > nginx.Warn {
c.JSON(http.StatusInternalServerError, gin.H{
"message": output,
})
return
}
}
GetStream(c)
}
func EnableStream(c *gin.Context) {
configFilePath := nginx.GetConfPath("streams-available", c.Param("name"))
enabledConfigFilePath := nginx.GetConfPath("streams-enabled", c.Param("name"))
_, err := os.Stat(configFilePath)
if err != nil {
api.ErrHandler(c, err)
return
}
if _, err = os.Stat(enabledConfigFilePath); os.IsNotExist(err) {
err = os.Symlink(configFilePath, enabledConfigFilePath)
if err != nil {
api.ErrHandler(c, err)
return
}
}
// Test nginx config, if not pass, then disable the stream.
output := nginx.TestConf()
if nginx.GetLogLevel(output) > nginx.Warn {
_ = os.Remove(enabledConfigFilePath)
c.JSON(http.StatusInternalServerError, gin.H{
"message": output,
})
return
}
output = nginx.Reload()
if nginx.GetLogLevel(output) > nginx.Warn {
c.JSON(http.StatusInternalServerError, gin.H{
"message": output,
})
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}
func DisableStream(c *gin.Context) {
enabledConfigFilePath := nginx.GetConfPath("streams-enabled", c.Param("name"))
_, err := os.Stat(enabledConfigFilePath)
if err != nil {
api.ErrHandler(c, err)
return
}
err = os.Remove(enabledConfigFilePath)
if err != nil {
api.ErrHandler(c, err)
return
}
output := nginx.Reload()
if nginx.GetLogLevel(output) > nginx.Warn {
c.JSON(http.StatusInternalServerError, gin.H{
"message": output,
})
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}
func DeleteStream(c *gin.Context) {
var err error
name := c.Param("name")
availablePath := nginx.GetConfPath("streams-available", name)
enabledPath := nginx.GetConfPath("streams-enabled", name)
if _, err = os.Stat(availablePath); os.IsNotExist(err) {
c.JSON(http.StatusNotFound, gin.H{
"message": "stream not found",
})
return
}
if _, err = os.Stat(enabledPath); err == nil {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "stream is enabled",
})
return
}
if err = os.Remove(availablePath); err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,78 @@
package system
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/kernal"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"golang.org/x/crypto/bcrypt"
"net/http"
)
func installLockStatus() bool {
return settings.ServerSettings.SkipInstallation || "" != settings.ServerSettings.JwtSecret
}
func InstallLockCheck(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"lock": installLockStatus(),
})
}
type InstallJson struct {
Email string `json:"email" binding:"required,email"`
Username string `json:"username" binding:"required,max=255"`
Password string `json:"password" binding:"required,max=255"`
Database string `json:"database"`
}
func InstallNginxUI(c *gin.Context) {
// Visit this api after installed is forbidden
if installLockStatus() {
c.JSON(http.StatusForbidden, gin.H{
"error": "installed",
})
return
}
var json InstallJson
ok := api.BindAndValid(c, &json)
if !ok {
return
}
settings.ServerSettings.JwtSecret = uuid.New().String()
settings.ServerSettings.NodeSecret = uuid.New().String()
settings.ServerSettings.Email = json.Email
if "" != json.Database {
settings.ServerSettings.Database = json.Database
}
err := settings.Save()
if err != nil {
api.ErrHandler(c, err)
return
}
// Init model
kernal.InitDatabase()
pwd, _ := bcrypt.GenerateFromPassword([]byte(json.Password), bcrypt.DefaultCost)
u := query.User
err = u.Create(&model.User{
Name: json.Username,
Password: string(pwd),
})
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,20 @@
package system
import (
"github.com/gin-gonic/gin"
)
func InitPublicRouter(r *gin.RouterGroup) {
r.GET("install", InstallLockCheck)
r.POST("install", InstallNginxUI)
r.GET("translation/:code", GetTranslation)
}
func InitPrivateRouter(r *gin.RouterGroup) {
r.GET("upgrade/release", GetRelease)
r.GET("upgrade/current", GetCurrentVersion)
}
func InitWebSocketRouter(r *gin.RouterGroup) {
r.GET("upgrade/perform", PerformCoreUpgrade)
}

@ -0,0 +1,13 @@
package system
import (
"github.com/0xJacky/Nginx-UI/internal/translation"
"github.com/gin-gonic/gin"
"net/http"
)
func GetTranslation(c *gin.Context) {
code := c.Param("code")
c.JSON(http.StatusOK, translation.GetTranslation(code))
}

@ -0,0 +1,156 @@
package system
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/upgrader"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"net/http"
"os"
)
func GetRelease(c *gin.Context) {
data, err := upgrader.GetRelease(c.Query("channel"))
if err != nil {
api.ErrHandler(c, err)
return
}
runtimeInfo, err := upgrader.GetRuntimeInfo()
if err != nil {
api.ErrHandler(c, err)
return
}
type resp struct {
upgrader.TRelease
upgrader.RuntimeInfo
}
c.JSON(http.StatusOK, resp{
data, runtimeInfo,
})
}
func GetCurrentVersion(c *gin.Context) {
curVer, err := upgrader.GetCurrentVersion()
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, curVer)
}
const (
UpgradeStatusInfo = "info"
UpgradeStatusError = "error"
UpgradeStatusProgress = "progress"
)
type CoreUpgradeResp struct {
Status string `json:"status"`
Progress float64 `json:"progress"`
Message string `json:"message"`
}
func PerformCoreUpgrade(c *gin.Context) {
var upGrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
// upgrade http to websocket
ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
logger.Error(err)
return
}
defer ws.Close()
var control struct {
DryRun bool `json:"dry_run"`
Channel string `json:"channel"`
}
err = ws.ReadJSON(&control)
if err != nil {
logger.Error(err)
return
}
_ = ws.WriteJSON(CoreUpgradeResp{
Status: UpgradeStatusInfo,
Message: "Initialing core upgrader",
})
u, err := upgrader.NewUpgrader(control.Channel)
if err != nil {
_ = ws.WriteJSON(CoreUpgradeResp{
Status: UpgradeStatusError,
Message: "Initial core upgrader error",
})
_ = ws.WriteJSON(CoreUpgradeResp{
Status: UpgradeStatusError,
Message: err.Error(),
})
logger.Error(err)
return
}
_ = ws.WriteJSON(CoreUpgradeResp{
Status: UpgradeStatusInfo,
Message: "Downloading latest release",
})
progressChan := make(chan float64)
go func() {
for progress := range progressChan {
_ = ws.WriteJSON(CoreUpgradeResp{
Status: UpgradeStatusProgress,
Progress: progress,
})
}
}()
tarName, err := u.DownloadLatestRelease(progressChan)
if err != nil {
_ = ws.WriteJSON(CoreUpgradeResp{
Status: UpgradeStatusError,
Message: "Download latest release error",
})
_ = ws.WriteJSON(CoreUpgradeResp{
Status: UpgradeStatusError,
Message: err.Error(),
})
logger.Error(err)
return
}
defer func() {
_ = os.Remove(tarName)
_ = os.Remove(tarName + ".digest")
}()
_ = ws.WriteJSON(CoreUpgradeResp{
Status: UpgradeStatusInfo,
Message: "Performing core upgrade",
})
// dry run
if control.DryRun || settings.ServerSettings.Demo {
return
}
// bye, will restart nginx-ui in performCoreUpgrade
err = u.PerformCoreUpgrade(tarName)
if err != nil {
_ = ws.WriteJSON(CoreUpgradeResp{
Status: UpgradeStatusError,
Message: "Perform core upgrade error",
})
_ = ws.WriteJSON(CoreUpgradeResp{
Status: UpgradeStatusError,
Message: err.Error(),
})
logger.Error(err)
return
}
}

@ -0,0 +1,11 @@
package template
import "github.com/gin-gonic/gin"
func InitRouter(r *gin.RouterGroup) {
r.GET("template", GetTemplate)
r.GET("template/configs", GetTemplateConfList)
r.GET("template/blocks", GetTemplateBlockList)
r.GET("template/block/:name", GetTemplateBlock)
r.POST("template/block/:name", GetTemplateBlock)
}

@ -1,8 +1,9 @@
package api
package template
import (
"github.com/0xJacky/Nginx-UI/server/pkg/nginx"
"github.com/0xJacky/Nginx-UI/server/service"
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/internal/template"
"github.com/gin-gonic/gin"
"net/http"
)
@ -32,22 +33,29 @@ func GetTemplate(c *gin.Context) {
Directive: "index",
},
},
Locations: []*nginx.NgxLocation{},
},
},
}
content, err := ngxConfig.BuildConfig()
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
"template": ngxConfig.BuildConfig(),
"template": content,
"tokenized": ngxConfig,
})
}
func GetTemplateConfList(c *gin.Context) {
configList, err := service.GetTemplateList("conf")
configList, err := template.GetTemplateList("conf")
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
@ -57,10 +65,10 @@ func GetTemplateConfList(c *gin.Context) {
}
func GetTemplateBlockList(c *gin.Context) {
configList, err := service.GetTemplateList("block")
configList, err := template.GetTemplateList("block")
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
@ -71,20 +79,20 @@ func GetTemplateBlockList(c *gin.Context) {
func GetTemplateBlock(c *gin.Context) {
type resp struct {
service.ConfigInfoItem
service.ConfigDetail
template.ConfigInfoItem
template.ConfigDetail
}
var bindData map[string]service.TVariable
var bindData map[string]template.Variable
_ = c.ShouldBindJSON(&bindData)
info := service.GetTemplateInfo("block", c.Param("name"))
info := template.GetTemplateInfo("block", c.Param("name"))
if bindData == nil {
bindData = info.Variables
}
detail, err := service.ParseTemplate("block", c.Param("name"), bindData)
detail, err := template.ParseTemplate("block", c.Param("name"), bindData)
if err != nil {
ErrHandler(c, err)
api.ErrHandler(c, err)
return
}
info.Variables = bindData

@ -1,10 +1,10 @@
package api
package terminal
import (
"github.com/0xJacky/Nginx-UI/server/pkg/pty"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/pty"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"log"
"net/http"
)
@ -17,7 +17,7 @@ func Pty(c *gin.Context) {
// upgrade http to websocket
ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
log.Println("pty ws upgrade error", err)
logger.Error(err)
return
}
@ -26,11 +26,11 @@ func Pty(c *gin.Context) {
p, err := pty.NewPipeLine(ws)
if err != nil {
log.Println("pty.NewPipLine error", err)
logger.Error(err)
return
}
defer p.Pty.Close()
defer p.Close()
errorChan := make(chan error, 1)
go p.ReadPtyAndWriteWs(errorChan)
@ -39,7 +39,7 @@ func Pty(c *gin.Context) {
err = <-errorChan
if err != nil {
log.Println(err)
logger.Error(err)
}
return

@ -0,0 +1,7 @@
package terminal
import "github.com/gin-gonic/gin"
func InitRouter(r *gin.RouterGroup) {
r.GET("pty", Pty)
}

@ -0,0 +1,7 @@
package upstream
import "github.com/gin-gonic/gin"
func InitRouter(r *gin.RouterGroup) {
r.GET("/availability_test", AvailabilityTest)
}

@ -0,0 +1,46 @@
package upstream
import (
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/upstream"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"net/http"
"time"
)
func AvailabilityTest(c *gin.Context) {
var upGrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
// upgrade http to websocket
ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
logger.Error(err)
return
}
defer ws.Close()
var body []string
err = ws.ReadJSON(&body)
if err != nil {
logger.Error(err)
return
}
for {
err = ws.WriteJSON(upstream.AvailabilityTest(body))
if helper.IsUnexpectedWebsocketError(err) {
logger.Error(err)
break
}
time.Sleep(10 * time.Second)
}
}

@ -0,0 +1,156 @@
package user
import (
"encoding/base64"
"fmt"
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/cache"
"github.com/0xJacky/Nginx-UI/internal/passkey"
"github.com/0xJacky/Nginx-UI/internal/user"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"github.com/go-webauthn/webauthn/webauthn"
"github.com/google/uuid"
"net/http"
"strings"
"time"
)
type Status2FA struct {
Enabled bool `json:"enabled"`
OTPStatus bool `json:"otp_status"`
PasskeyStatus bool `json:"passkey_status"`
}
func get2FAStatus(c *gin.Context) (status Status2FA) {
// when accessing the node from the main cluster, there is no user in the context
u, ok := c.Get("user")
if ok {
userPtr := u.(*model.User)
status.OTPStatus = userPtr.EnabledOTP()
status.PasskeyStatus = userPtr.EnabledPasskey() && passkey.Enabled()
status.Enabled = status.OTPStatus || status.PasskeyStatus
}
return
}
func Get2FAStatus(c *gin.Context) {
c.JSON(http.StatusOK, get2FAStatus(c))
}
func SecureSessionStatus(c *gin.Context) {
status2FA := get2FAStatus(c)
if !status2FA.Enabled {
c.JSON(http.StatusOK, gin.H{
"status": false,
})
return
}
ssid := c.GetHeader("X-Secure-Session-ID")
if ssid == "" {
ssid = c.Query("X-Secure-Session-ID")
}
if ssid == "" {
c.JSON(http.StatusOK, gin.H{
"status": false,
})
return
}
u := api.CurrentUser(c)
c.JSON(http.StatusOK, gin.H{
"status": user.VerifySecureSessionID(ssid, u.ID),
})
}
func Start2FASecureSessionByOTP(c *gin.Context) {
var json struct {
OTP string `json:"otp"`
RecoveryCode string `json:"recovery_code"`
}
if !api.BindAndValid(c, &json) {
return
}
u := api.CurrentUser(c)
if !u.EnabledOTP() {
c.JSON(http.StatusBadRequest, gin.H{
"message": "User has not configured OTP as 2FA",
})
return
}
if json.OTP == "" && json.RecoveryCode == "" {
c.JSON(http.StatusBadRequest, LoginResponse{
Message: "The user has enabled OTP as 2FA",
})
return
}
if err := user.VerifyOTP(u, json.OTP, json.RecoveryCode); err != nil {
c.JSON(http.StatusBadRequest, LoginResponse{
Message: "Invalid OTP or recovery code",
})
return
}
sessionId := user.SetSecureSessionID(u.ID)
c.JSON(http.StatusOK, gin.H{
"session_id": sessionId,
})
}
func BeginStart2FASecureSessionByPasskey(c *gin.Context) {
if !passkey.Enabled() {
api.ErrHandler(c, fmt.Errorf("WebAuthn settings are not configured"))
return
}
webauthnInstance := passkey.GetInstance()
u := api.CurrentUser(c)
options, sessionData, err := webauthnInstance.BeginLogin(u)
if err != nil {
api.ErrHandler(c, err)
return
}
passkeySessionID := uuid.NewString()
cache.Set(passkeySessionID, sessionData, passkeyTimeout)
c.JSON(http.StatusOK, gin.H{
"session_id": passkeySessionID,
"options": options,
})
}
func FinishStart2FASecureSessionByPasskey(c *gin.Context) {
if !passkey.Enabled() {
api.ErrHandler(c, fmt.Errorf("WebAuthn settings are not configured"))
return
}
passkeySessionID := c.GetHeader("X-Passkey-Session-ID")
sessionDataBytes, ok := cache.Get(passkeySessionID)
if !ok {
api.ErrHandler(c, fmt.Errorf("session not found"))
return
}
sessionData := sessionDataBytes.(*webauthn.SessionData)
webauthnInstance := passkey.GetInstance()
u := api.CurrentUser(c)
credential, err := webauthnInstance.FinishLogin(u, *sessionData, c.Request)
if err != nil {
api.ErrHandler(c, err)
return
}
rawID := strings.TrimRight(base64.StdEncoding.EncodeToString(credential.ID), "=")
p := query.Passkey
_, _ = p.Where(p.RawID.Eq(rawID)).Updates(&model.Passkey{
LastUsedAt: time.Now().Unix(),
})
sessionId := user.SetSecureSessionID(u.ID)
c.JSON(http.StatusOK, gin.H{
"session_id": sessionId,
})
}

@ -0,0 +1,142 @@
package user
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/user"
"github.com/0xJacky/Nginx-UI/query"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"math/rand/v2"
"net/http"
"sync"
"time"
)
var mutex = &sync.Mutex{}
type LoginUser struct {
Name string `json:"name" binding:"required,max=255"`
Password string `json:"password" binding:"required,max=255"`
OTP string `json:"otp"`
RecoveryCode string `json:"recovery_code"`
}
const (
ErrPasswordIncorrect = 4031
ErrMaxAttempts = 4291
ErrUserBanned = 4033
Enabled2FA = 199
Error2FACode = 4034
LoginSuccess = 200
)
type LoginResponse struct {
Message string `json:"message"`
Error string `json:"error,omitempty"`
Code int `json:"code"`
Token string `json:"token,omitempty"`
SecureSessionID string `json:"secure_session_id,omitempty"`
}
func Login(c *gin.Context) {
// make sure that only one request is processed at a time
mutex.Lock()
defer mutex.Unlock()
// check if the ip is banned
clientIP := c.ClientIP()
b := query.BanIP
banIP, _ := b.Where(b.IP.Eq(clientIP),
b.ExpiredAt.Gte(time.Now().Unix()),
b.Attempts.Gte(settings.AuthSettings.MaxAttempts),
).Count()
if banIP > 0 {
c.JSON(http.StatusTooManyRequests, LoginResponse{
Message: "Max attempts",
Code: ErrMaxAttempts,
})
return
}
var json LoginUser
ok := api.BindAndValid(c, &json)
if !ok {
return
}
u, err := user.Login(json.Name, json.Password)
if err != nil {
random := time.Duration(rand.Int() % 10)
time.Sleep(random * time.Second)
switch {
case errors.Is(err, user.ErrPasswordIncorrect):
c.JSON(http.StatusForbidden, LoginResponse{
Message: "Password incorrect",
Code: ErrPasswordIncorrect,
})
case errors.Is(err, user.ErrUserBanned):
c.JSON(http.StatusForbidden, LoginResponse{
Message: "The user is banned",
Code: ErrUserBanned,
})
default:
api.ErrHandler(c, err)
}
user.BanIP(clientIP)
return
}
// Check if the user enables 2FA
var secureSessionID string
if u.EnabledOTP() {
if json.OTP == "" && json.RecoveryCode == "" {
c.JSON(http.StatusOK, LoginResponse{
Message: "The user has enabled 2FA",
Code: Enabled2FA,
})
user.BanIP(clientIP)
return
}
if err = user.VerifyOTP(u, json.OTP, json.RecoveryCode); err != nil {
c.JSON(http.StatusForbidden, LoginResponse{
Message: "Invalid 2FA or recovery code",
Code: Error2FACode,
})
user.BanIP(clientIP)
return
}
secureSessionID = user.SetSecureSessionID(u.ID)
}
// login success, clear banned record
_, _ = b.Where(b.IP.Eq(clientIP)).Delete()
logger.Info("[User Login]", u.Name)
token, err := user.GenerateJWT(u)
if err != nil {
c.JSON(http.StatusInternalServerError, LoginResponse{
Message: err.Error(),
})
return
}
c.JSON(http.StatusOK, LoginResponse{
Code: LoginSuccess,
Message: "ok",
Token: token,
SecureSessionID: secureSessionID,
})
}
func Logout(c *gin.Context) {
token := c.GetHeader("Authorization")
if token != "" {
user.DeleteToken(token)
}
c.JSON(http.StatusNoContent, nil)
}

@ -0,0 +1,98 @@
package user
import (
"fmt"
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/user"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/casdoor/casdoor-go-sdk/casdoorsdk"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"gorm.io/gorm"
"net/http"
"net/url"
)
type CasdoorLoginUser struct {
Code string `json:"code" binding:"required,max=255"`
State string `json:"state" binding:"required,max=255"`
}
func CasdoorCallback(c *gin.Context) {
var loginUser CasdoorLoginUser
ok := api.BindAndValid(c, &loginUser)
if !ok {
return
}
endpoint := settings.CasdoorSettings.Endpoint
clientId := settings.CasdoorSettings.ClientId
clientSecret := settings.CasdoorSettings.ClientSecret
certificate := settings.CasdoorSettings.Certificate
organization := settings.CasdoorSettings.Organization
application := settings.CasdoorSettings.Application
if endpoint == "" || clientId == "" || clientSecret == "" || certificate == "" || organization == "" || application == "" {
c.JSON(http.StatusInternalServerError, gin.H{
"message": "Casdoor is not configured",
})
return
}
casdoorsdk.InitConfig(endpoint, clientId, clientSecret, certificate, organization, application)
token, err := casdoorsdk.GetOAuthToken(loginUser.Code, loginUser.State)
if err != nil {
api.ErrHandler(c, err)
return
}
claims, err := casdoorsdk.ParseJwtToken(token.AccessToken)
if err != nil {
api.ErrHandler(c, err)
return
}
u, err := user.GetUser(claims.Name)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
c.JSON(http.StatusForbidden, gin.H{
"message": "User not exist",
})
} else {
api.ErrHandler(c, err)
}
return
}
userToken, err := user.GenerateJWT(u)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, LoginResponse{
Message: "ok",
Token: userToken,
})
}
func GetCasdoorUri(c *gin.Context) {
endpoint := settings.CasdoorSettings.Endpoint
clientId := settings.CasdoorSettings.ClientId
redirectUri := settings.CasdoorSettings.RedirectUri
state := settings.CasdoorSettings.Application
if endpoint == "" || clientId == "" || redirectUri == "" || state == "" {
c.JSON(http.StatusOK, gin.H{
"uri": "",
})
return
}
encodedRedirectUri := url.QueryEscape(redirectUri)
c.JSON(http.StatusOK, gin.H{
"uri": fmt.Sprintf("%s/login/oauth/authorize?client_id=%s&response_type=code&redirect_uri=%s&state=%s&scope=read", endpoint, clientId, encodedRedirectUri, state),
})
}

@ -0,0 +1,147 @@
package user
import (
"bytes"
"crypto/sha1"
"encoding/base64"
"encoding/hex"
"fmt"
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/crypto"
"github.com/0xJacky/Nginx-UI/query"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/pquerna/otp"
"github.com/pquerna/otp/totp"
"image/jpeg"
"net/http"
"strings"
)
func GenerateTOTP(c *gin.Context) {
u := api.CurrentUser(c)
issuer := fmt.Sprintf("Nginx UI %s", settings.ServerSettings.Name)
issuer = strings.TrimSpace(issuer)
otpOpts := totp.GenerateOpts{
Issuer: issuer,
AccountName: u.Name,
Period: 30, // seconds
Digits: otp.DigitsSix,
Algorithm: otp.AlgorithmSHA1,
}
otpKey, err := totp.Generate(otpOpts)
if err != nil {
api.ErrHandler(c, err)
return
}
qrCode, err := otpKey.Image(512, 512)
if err != nil {
api.ErrHandler(c, err)
return
}
// Encode the image to a buffer
var buf []byte
buffer := bytes.NewBuffer(buf)
err = jpeg.Encode(buffer, qrCode, nil)
if err != nil {
fmt.Println("Error encoding image:", err)
return
}
// Convert the buffer to a base64 string
base64Str := "data:image/jpeg;base64," + base64.StdEncoding.EncodeToString(buffer.Bytes())
c.JSON(http.StatusOK, gin.H{
"secret": otpKey.Secret(),
"qr_code": base64Str,
})
}
func EnrollTOTP(c *gin.Context) {
cUser := api.CurrentUser(c)
if cUser.EnabledOTP() {
c.JSON(http.StatusBadRequest, gin.H{
"message": "User already enrolled",
})
return
}
if settings.ServerSettings.Demo {
c.JSON(http.StatusBadRequest, gin.H{
"message": "This feature is disabled in demo mode",
})
return
}
var json struct {
Secret string `json:"secret" binding:"required"`
Passcode string `json:"passcode" binding:"required"`
}
if !api.BindAndValid(c, &json) {
return
}
if ok := totp.Validate(json.Passcode, json.Secret); !ok {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "Invalid passcode",
})
return
}
ciphertext, err := crypto.AesEncrypt([]byte(json.Secret))
if err != nil {
api.ErrHandler(c, err)
return
}
u := query.User
_, err = u.Where(u.ID.Eq(cUser.ID)).Update(u.OTPSecret, ciphertext)
if err != nil {
api.ErrHandler(c, err)
return
}
recoveryCode := sha1.Sum(ciphertext)
c.JSON(http.StatusOK, gin.H{
"message": "ok",
"recovery_code": hex.EncodeToString(recoveryCode[:]),
})
}
func ResetOTP(c *gin.Context) {
var json struct {
RecoveryCode string `json:"recovery_code"`
}
if !api.BindAndValid(c, &json) {
return
}
recoverCode, err := hex.DecodeString(json.RecoveryCode)
if err != nil {
api.ErrHandler(c, err)
return
}
cUser := api.CurrentUser(c)
k := sha1.Sum(cUser.OTPSecret)
if !bytes.Equal(k[:], recoverCode) {
c.JSON(http.StatusBadRequest, gin.H{
"message": "Invalid recovery code",
})
return
}
u := query.User
_, err = u.Where(u.ID.Eq(cUser.ID)).UpdateSimple(u.OTPSecret.Null())
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}

@ -0,0 +1,195 @@
package user
import (
"encoding/base64"
"fmt"
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/cache"
"github.com/0xJacky/Nginx-UI/internal/cosy"
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/passkey"
"github.com/0xJacky/Nginx-UI/internal/user"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/gin-gonic/gin"
"github.com/go-webauthn/webauthn/webauthn"
"github.com/google/uuid"
"github.com/spf13/cast"
"gorm.io/gorm"
"net/http"
"strings"
"time"
)
const passkeyTimeout = 30 * time.Second
func buildCachePasskeyRegKey(id int) string {
return fmt.Sprintf("passkey-reg-%d", id)
}
func GetPasskeyConfigStatus(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"status": passkey.Enabled(),
})
}
func BeginPasskeyRegistration(c *gin.Context) {
u := api.CurrentUser(c)
webauthnInstance := passkey.GetInstance()
options, sessionData, err := webauthnInstance.BeginRegistration(u)
if err != nil {
api.ErrHandler(c, err)
return
}
cache.Set(buildCachePasskeyRegKey(u.ID), sessionData, passkeyTimeout)
c.JSON(http.StatusOK, options)
}
func FinishPasskeyRegistration(c *gin.Context) {
cUser := api.CurrentUser(c)
webauthnInstance := passkey.GetInstance()
sessionDataBytes, ok := cache.Get(buildCachePasskeyRegKey(cUser.ID))
if !ok {
api.ErrHandler(c, fmt.Errorf("session not found"))
return
}
sessionData := sessionDataBytes.(*webauthn.SessionData)
credential, err := webauthnInstance.FinishRegistration(cUser, *sessionData, c.Request)
if err != nil {
api.ErrHandler(c, err)
return
}
cache.Del(buildCachePasskeyRegKey(cUser.ID))
rawId := strings.TrimRight(base64.StdEncoding.EncodeToString(credential.ID), "=")
passkeyName := c.Query("name")
p := query.Passkey
err = p.Create(&model.Passkey{
UserID: cUser.ID,
Name: passkeyName,
RawID: rawId,
Credential: credential,
LastUsedAt: time.Now().Unix(),
})
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": "ok",
})
}
func BeginPasskeyLogin(c *gin.Context) {
if !passkey.Enabled() {
api.ErrHandler(c, fmt.Errorf("WebAuthn settings are not configured"))
return
}
webauthnInstance := passkey.GetInstance()
options, sessionData, err := webauthnInstance.BeginDiscoverableLogin()
if err != nil {
api.ErrHandler(c, err)
return
}
sessionID := uuid.NewString()
cache.Set(sessionID, sessionData, passkeyTimeout)
c.JSON(http.StatusOK, gin.H{
"session_id": sessionID,
"options": options,
})
}
func FinishPasskeyLogin(c *gin.Context) {
if !passkey.Enabled() {
api.ErrHandler(c, fmt.Errorf("WebAuthn settings are not configured"))
return
}
sessionId := c.GetHeader("X-Passkey-Session-ID")
sessionDataBytes, ok := cache.Get(sessionId)
if !ok {
api.ErrHandler(c, fmt.Errorf("session not found"))
return
}
webauthnInstance := passkey.GetInstance()
sessionData := sessionDataBytes.(*webauthn.SessionData)
var outUser *model.User
_, err := webauthnInstance.FinishDiscoverableLogin(
func(rawID, userHandle []byte) (user webauthn.User, err error) {
encodeRawID := strings.TrimRight(base64.StdEncoding.EncodeToString(rawID), "=")
u := query.User
logger.Debug("[WebAuthn] Discoverable Login", cast.ToInt(string(userHandle)))
p := query.Passkey
_, _ = p.Where(p.RawID.Eq(encodeRawID)).Updates(&model.Passkey{
LastUsedAt: time.Now().Unix(),
})
outUser, err = u.FirstByID(cast.ToInt(string(userHandle)))
return outUser, err
}, *sessionData, c.Request)
if err != nil {
api.ErrHandler(c, err)
return
}
b := query.BanIP
clientIP := c.ClientIP()
// login success, clear banned record
_, _ = b.Where(b.IP.Eq(clientIP)).Delete()
logger.Info("[User Login]", outUser.Name)
token, err := user.GenerateJWT(outUser)
if err != nil {
c.JSON(http.StatusInternalServerError, LoginResponse{
Message: err.Error(),
})
return
}
c.JSON(http.StatusOK, LoginResponse{
Code: LoginSuccess,
Message: "ok",
Token: token,
// SecureSessionID: secureSessionID,
})
}
func GetPasskeyList(c *gin.Context) {
u := api.CurrentUser(c)
p := query.Passkey
passkeys, err := p.Where(p.UserID.Eq(u.ID)).Find()
if err != nil {
api.ErrHandler(c, err)
return
}
if len(passkeys) == 0 {
passkeys = make([]*model.Passkey, 0)
}
c.JSON(http.StatusOK, passkeys)
}
func UpdatePasskey(c *gin.Context) {
u := api.CurrentUser(c)
cosy.Core[model.Passkey](c).
SetValidRules(gin.H{
"name": "required",
}).GormScope(func(tx *gorm.DB) *gorm.DB {
return tx.Where("user_id", u.ID)
}).Modify()
}
func DeletePasskey(c *gin.Context) {
u := api.CurrentUser(c)
cosy.Core[model.Passkey](c).
GormScope(func(tx *gorm.DB) *gorm.DB {
return tx.Where("user_id", u.ID)
}).PermanentlyDelete()
}

@ -0,0 +1,46 @@
package user
import (
"github.com/gin-gonic/gin"
)
func InitAuthRouter(r *gin.RouterGroup) {
r.POST("/login", Login)
r.DELETE("/logout", Logout)
r.GET("/begin_passkey_login", BeginPasskeyLogin)
r.POST("/finish_passkey_login", FinishPasskeyLogin)
r.GET("/casdoor_uri", GetCasdoorUri)
r.POST("/casdoor_callback", CasdoorCallback)
r.GET("/passkeys/config", GetPasskeyConfigStatus)
}
func InitManageUserRouter(r *gin.RouterGroup) {
r.GET("users", GetUsers)
r.GET("user/:id", GetUser)
r.POST("user", AddUser)
r.POST("user/:id", EditUser)
r.DELETE("user/:id", DeleteUser)
r.PATCH("user/:id", RecoverUser)
}
func InitUserRouter(r *gin.RouterGroup) {
r.GET("/2fa_status", Get2FAStatus)
r.GET("/2fa_secure_session/status", SecureSessionStatus)
r.POST("/2fa_secure_session/otp", Start2FASecureSessionByOTP)
r.GET("/2fa_secure_session/passkey", BeginStart2FASecureSessionByPasskey)
r.POST("/2fa_secure_session/passkey", FinishStart2FASecureSessionByPasskey)
r.GET("/otp_secret", GenerateTOTP)
r.POST("/otp_enroll", EnrollTOTP)
r.POST("/otp_reset", ResetOTP)
r.GET("/begin_passkey_register", BeginPasskeyRegistration)
r.POST("/finish_passkey_register", FinishPasskeyRegistration)
r.GET("/passkeys", GetPasskeyList)
r.POST("/passkeys/:id", UpdatePasskey)
r.DELETE("/passkeys/:id", DeletePasskey)
}

@ -0,0 +1,132 @@
package user
import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/cosy"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/spf13/cast"
"golang.org/x/crypto/bcrypt"
"net/http"
)
func GetUsers(c *gin.Context) {
cosy.Core[model.User](c).SetFussy("name").PagingList()
}
func GetUser(c *gin.Context) {
id := cast.ToInt(c.Param("id"))
u := query.User
user, err := u.FirstByID(id)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, user)
}
type UserJson struct {
Name string `json:"name" binding:"required,max=255"`
Password string `json:"password" binding:"max=255"`
}
func AddUser(c *gin.Context) {
var json UserJson
ok := api.BindAndValid(c, &json)
if !ok {
return
}
u := query.User
pwd, err := bcrypt.GenerateFromPassword([]byte(json.Password), bcrypt.DefaultCost)
if err != nil {
api.ErrHandler(c, err)
return
}
json.Password = string(pwd)
user := model.User{
Name: json.Name,
Password: json.Password,
}
err = u.Create(&user)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, user)
}
func EditUser(c *gin.Context) {
userId := cast.ToInt(c.Param("id"))
if settings.ServerSettings.Demo && userId == 1 {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "Changing user password is forbidden in demo mode",
})
return
}
var json UserJson
ok := api.BindAndValid(c, &json)
if !ok {
return
}
u := query.User
user, err := u.FirstByID(userId)
if err != nil {
api.ErrHandler(c, err)
return
}
edit := &model.User{
Name: json.Name,
}
// encrypt password
if json.Password != "" {
var pwd []byte
pwd, err = bcrypt.GenerateFromPassword([]byte(json.Password), bcrypt.DefaultCost)
if err != nil {
api.ErrHandler(c, err)
return
}
edit.Password = string(pwd)
}
_, err = u.Where(u.ID.Eq(userId)).Updates(&edit)
if err != nil {
api.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, user)
}
func DeleteUser(c *gin.Context) {
id := cast.ToInt(c.Param("id"))
if cast.ToInt(id) == 1 {
c.JSON(http.StatusNotAcceptable, gin.H{
"message": "Prohibit deleting the default user",
})
return
}
cosy.Core[model.User](c).Destroy()
}
func RecoverUser(c *gin.Context) {
cosy.Core[model.User](c).Recover()
}

@ -1,29 +1,67 @@
; suppress inspection "DuplicateKeyInSection" for whole file
[server]
HttpPort = 9000
RunMode = debug
JwtSecret =
Email =
HTTPChallengePort = 9180
StartCmd = login
Database = database
CADir =
Demo =
GithubProxy =
NginxConfigDir =
[nginx_log]
HttpPort = 9000
RunMode = debug
JwtSecret =
Email =
HTTPChallengePort = 9180
StartCmd = bash
Database = database
CADir =
GithubProxy =
NodeSecret =
Demo = false
PageSize = 10
HttpHost = 0.0.0.0
CertRenewalInterval = 7
RecursiveNameservers =
SkipInstallation = false
Name =
InsecureSkipVerify = false
[nginx]
AccessLogPath = /var/log/nginx/access.log
ErrorLogPath = /var/log/nginx/error.log
ErrorLogPath = /var/log/nginx/error.log
ConfigDir =
PIDPath =
TestConfigCmd =
ReloadCmd =
RestartCmd =
[openai]
Model =
BaseUrl =
Proxy =
Token =
[git]
Url =
AuthMethod =
Username =
Password =
PrivateKeyFile =
Model =
BaseUrl =
Proxy =
Token =
[casdoor]
Endpoint =
ClientId =
ClientSecret =
Certificate =
Organization =
Application =
RedirectUri =
[logrotate]
Enabled = false
CMD = logrotate /etc/logrotate.d/nginx
Interval = 1440
[cluster]
Node = http://10.0.0.1:9000?name=node1&node_secret=my-node-secret&enabled=true
Node = http://10.0.0.2:9000?name=node2&node_secret=my-node-secret&enabled=true
Node = http://10.0.0.3?name=node3&node_secret=my-node-secret&enabled=true
[auth]
IPWhiteList =
BanThresholdMinutes = 10
MaxAttempts = 10
[crypto]
Secret = secret2
[webauthn]
RPDisplayName =
RPID =
RPOrigins =

@ -0,0 +1 @@
VITE_PROXY_TARGET=http://127.0.0.1:9001

@ -0,0 +1,257 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'@antfu/eslint-config-vue',
'plugin:vue/vue3-recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:sonarjs/recommended',
'plugin:@typescript-eslint/recommended',
// 'plugin:unicorn/recommended',
],
parser: 'vue-eslint-parser',
parserOptions: {
ecmaVersion: 13,
parser: '@typescript-eslint/parser',
sourceType: 'module',
},
plugins: [
'vue',
'@typescript-eslint',
'regex',
],
ignorePatterns: ['src/@iconify/*.js', 'node_modules', 'dist', '*.d.ts'],
rules: {
'vue/no-v-html': 'off',
'vue/block-tag-newline': 'off',
// eslint-disable-next-line n/prefer-global/process
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
// eslint-disable-next-line n/prefer-global/process
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
// indentation (Already present in TypeScript)
'comma-spacing': ['error', {
before: false,
after: true,
}],
'key-spacing': ['error', {afterColon: true}],
'vue/first-attribute-linebreak': ['error', {
singleline: 'beside',
multiline: 'below',
}],
'antfu/top-level-function': 'off',
// Enforce trailing comma (Already present in TypeScript)
'comma-dangle': ['error', 'always-multiline'],
// Disable max-len
'max-len': 'off',
// we don't want it
'semi': ['error', 'never'],
// add parens ony when required in arrow function
'arrow-parens': ['error', 'as-needed'],
// add new line above comment
'newline-before-return': 'error',
// add new line above comment
'lines-around-comment': [
'error',
{
beforeBlockComment: true,
beforeLineComment: true,
allowBlockStart: true,
allowClassStart: true,
allowObjectStart: true,
allowArrayStart: true,
},
],
// Ignore _ as unused variable
'@typescript-eslint/no-unused-vars': ['error', {argsIgnorePattern: '^_+$'}],
'array-element-newline': ['error', 'consistent'],
'array-bracket-newline': ['error', 'consistent'],
'vue/multi-word-component-names': 'off',
'padding-line-between-statements': [
'error',
{
blankLine: 'always',
prev: 'expression',
next: 'const',
},
{
blankLine: 'always',
prev: 'const',
next: 'expression',
},
{
blankLine: 'always',
prev: 'multiline-const',
next: '*',
},
{
blankLine: 'always',
prev: '*',
next: 'multiline-const',
},
],
// Plugin: eslint-plugin-import
'import/prefer-default-export': 'off',
'import/newline-after-import': ['error', {count: 1}],
'no-restricted-imports': ['error', 'vuetify/components'],
// For omitting extension for ts files
'import/extensions': [
'error',
'ignorePackages',
{
mjs: 'never',
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
// ignore virtual files
'import/no-unresolved': [2, {
ignore: [
'~pages$',
'virtual:generated-layouts',
// Ignore vite's ?raw imports
'.*\?raw',
],
}],
// Thanks: https://stackoverflow.com/a/63961972/10796681
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
'@typescript-eslint/consistent-type-imports': 'error',
// Plugin: eslint-plugin-promise
'promise/always-return': 'off',
'promise/catch-or-return': 'off',
// ESLint plugin vue
'vue/component-api-style': 'error',
'vue/component-name-in-template-casing': ['error', 'PascalCase', {registeredComponentsOnly: false}],
'vue/custom-event-name-casing': ['error', 'camelCase', {
ignores: [
'/^(click):[a-z]+((\d)|([A-Z0-9][a-z0-9]+))*([A-Z])?/',
],
}],
'vue/define-macros-order': 'error',
'vue/html-comment-content-newline': 'error',
'vue/html-comment-content-spacing': 'error',
'vue/html-comment-indent': 'error',
'vue/match-component-file-name': 'error',
'vue/no-child-content': 'error',
'vue/require-default-prop': 'off',
// NOTE this rule only supported in SFC, Users of the unplugin-vue-define-options should disable that rule: https://github.com/vuejs/eslint-plugin-vue/issues/1886
// 'vue/no-duplicate-attr-inheritance': 'error',
'vue/no-multiple-objects-in-class': 'error',
'vue/no-reserved-component-names': 'error',
'vue/no-template-target-blank': 'error',
'vue/no-useless-mustaches': 'error',
'vue/no-useless-v-bind': 'error',
'vue/padding-line-between-blocks': 'error',
'vue/prefer-separate-static-class': 'error',
'vue/prefer-true-attribute-shorthand': 'error',
'vue/v-on-function-call': 'error',
'vue/valid-v-slot': ['error', {
allowModifiers: true,
}],
// -- Extension Rules
'vue/no-irregular-whitespace': 'error',
// -- Sonarlint
'sonarjs/no-duplicate-string': 'off',
'sonarjs/no-nested-template-literals': 'off',
// -- Unicorn
// 'unicorn/filename-case': 'off',
// 'unicorn/prevent-abbreviations': ['error', {
// replacements: {
// props: false,
// },
// }],
// https://github.com/gmullerb/eslint-plugin-regex
'regex/invalid': [
'error',
[
{
regex: '@/assets/images',
replacement: '@images',
message: 'Use \'@images\' path alias for image imports',
},
{
regex: '@/styles',
replacement: '@styles',
message: 'Use \'@styles\' path alias for importing styles from \'src/styles\'',
},
// {
// id: 'Disallow icon of icon library',
// regex: 'tabler-\\w',
// message: 'Only \'mdi\' icons are allowed',
// },
{
regex: '@core/\\w',
message: 'You can\'t use @core when you are in @layouts module',
files: {
inspect: '@layouts/.*',
},
},
{
regex: 'useLayouts\\(',
message: '`useLayouts` composable is only allowed in @layouts & @core directory. Please use `useThemeConfig` composable instead.',
files: {
inspect: '^(?!.*(@core|@layouts)).*',
},
},
],
// Ignore files
'\.eslintrc\.js',
],
},
settings: {
'import/resolver': {
node: {
extensions: ['.ts', '.js', '.tsx', '.jsx', '.mjs', '.png', '.jpg'],
},
typescript: {},
alias: {
map: [
['@', './src'],
],
},
},
},
overrides: [
{
files: ['*.json'],
rules: {
'no-invalid-meta': 'off',
},
},
],
}

@ -10,16 +10,12 @@ lerna-debug.log*
# deps
node_modules
dist
dist-ssr
*.local
docs/.vitepress/cache/*
.yarn
cache
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*

@ -0,0 +1,7 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# GitHub Copilot persisted chat sessions
/copilot/chatSessions

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
<excludeFolder url="file://$MODULE_DIR$/dist" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="ERROR" enabled_by_default="true" editorAttributes="ERRORS_ATTRIBUTES" />
</profile>
</component>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EslintConfiguration">
<custom-configuration-file used="false" path="$PROJECT_DIR$/.eslintrc.cjs" />
<option name="fix-on-save" value="true" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/frontend.iml" filepath="$PROJECT_DIR$/.idea/frontend.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectTasksOptions" suppressed-tasks="Less" />
</project>

@ -0,0 +1,5 @@
{
"recommendations": [
"Vue.volar"
]
}

@ -21,3 +21,47 @@ manual `h(...)` calls), you can enable Volar's Take Over mode by following these
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
## Project Setup
```sh
pnpm install
```
**Note:** The default target of the api proxy is `http://localhost:9000`,
if you need to change this, create the `.env` file in root directory and set your target in it.
```env
VITE_PROXY_TARGET=http://localhost:9001
```
### Compile and Hot-Reload for Development
```sh
pnpm dev
```
**Note:** The default port of the dev server is `3002`,
if you need to change this, create the `.env` file in root directory and set your port in it.
```env
VITE_PORT=3456
```
### Code Style Check
```sh
pnpm lint
```
### Type Check
```sh
pnpm typecheck
```
### Compile and Minify for Production
```sh
pnpm build
```

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save