diff --git a/backend/README.md b/backend/README.md index 091d1fa..07f34a9 100644 --- a/backend/README.md +++ b/backend/README.md @@ -2,21 +2,21 @@ ## BACKEND -Uses Node.js as backend for API, nginx for static. -Proxies logs from [app](https://github.com/serguun42/mss/tree/master/app) to [notifier](https://github.com/serguun42/mss/tree/master/notifier). - -### `nginx` -Uses nginx as server for static and as reverse-proxy for API. See [nginxconfig.io](https://nginxconfig.io/) and [nginx.base.conf](./nginx.base.conf) +Node.js for serving API of MSS. ## Commands -1. Install all dependencies `npm i --only=prod` -2. Run backend with PM2 `npm run production` +1. Install all dependencies `npm ci --omit=dev` +2. Run backend in production mode `npm run production` + +## Configs + +`backend.config.json` – Config file with ports, DB, logging, rate limiter + +## Tests -## Some folders +Check with Jest – `npm run test`, see tests themselves in [`tests` folder](./tests/). -* `utils` – Common util scripts like DB handler, logger or parsers -* `pages` – Backend side for some pages, e.g. `/` -> `index.js`, `/api` -> `api.js` +## Monitoring -## Some other files -`backend.config.json` – Config file with ports, DB, logging, rate limiter +This backend serves for Prometheus monitoring at `/metrics`. Check global [Docker Compose file](../docker-compose.yml) and [`prometheus.yml`](../monitoring/prometheus.yml). diff --git a/frontend/README.md b/frontend/README.md index 8684430..06aae99 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -2,14 +2,14 @@ ## Frontend -Built with Vue.js 2, 🚴🏻‍♀️ +Built with **Vue.js 2**. ## Commands -1. Install all dependencies `npm i` (pass `--omit=dev` to install only necessary deps) +1. Install all dependencies `npm ci` (pass `--omit=dev` to install only necessary deps) 2. Build front from sources `npm run build` ## Config -- `src/config/production.env` – donenv with variables (`src/config/local.env` for local dev mode) -- `vue.config.js` – Configuration for Vue, Webpack and its plugins, building static meta files and creating environment +- `src/config/production.env` – donenv with variables (`src/config/local.env` for local dev mode) +- `vue.config.js` – Configuration for Vue, Webpack and its plugins, building static meta files and creating environment diff --git a/frontend/package.json b/frontend/package.json index 2f03449..32821f5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "1.3.3", + "version": "1.4.0", "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", diff --git a/frontend/src/components/SiteFooter.vue b/frontend/src/components/SiteFooter.vue index 7e3f70a..54fd09f 100644 --- a/frontend/src/components/SiteFooter.vue +++ b/frontend/src/components/SiteFooter.vue @@ -1,8 +1,13 @@ \ No newline at end of file + diff --git a/frontend/src/config/production.env b/frontend/src/config/production.env index 8dd15c4..3a0b690 100644 --- a/frontend/src/config/production.env +++ b/frontend/src/config/production.env @@ -9,3 +9,4 @@ VUE_APP_OPENGRAPH_DESCRIPTION=mirea.xyz – Расписание МИРЭА дл VUE_APP_OPENGRAPH_IMAGE=/img/logo_wide.png VUE_APP_OPENGRAPH_SITE_NAME=mirea.xyz VUE_APP_CACHE_STORAGE_NAME=cache_static_and_dynamic_with_api +VUE_APP_PANEL_URL=https://panel.mirea.xyz/params-panel/ diff --git a/healthcheck/README.md b/healthcheck/README.md new file mode 100644 index 0000000..8852804 --- /dev/null +++ b/healthcheck/README.md @@ -0,0 +1,9 @@ +# MIREA Schedule System + +## Healthcheck + +Standalone healthcheck for MSS considered to be deployed on Cloud serverless container. + +### Config + +Check file [healthcheck.config.json](./healthcheck.config.json) for target server. diff --git a/monitoring/prometheus.yml b/monitoring/prometheus.yml index 5caebdd..836ae8f 100644 --- a/monitoring/prometheus.yml +++ b/monitoring/prometheus.yml @@ -2,6 +2,6 @@ global: scrape_interval: 5s scrape_configs: - - job_name: "backend-server" + - job_name: "mss-backend" static_configs: - - targets: ["172.25.240.1:80"] + - targets: ["mss-backend:80"] diff --git a/panel/panel.js b/panel/panel.js index f73e7c3..084cced 100644 --- a/panel/panel.js +++ b/panel/panel.js @@ -101,14 +101,24 @@ createServer((req, res) => { return; } + const sendingHeaders = req.headers; + sendingHeaders.host = "grafana"; + delete sendingHeaders["X-Real-IP"]; + delete sendingHeaders["Forwarded"]; + delete sendingHeaders["X-Forwarded-For"]; + delete sendingHeaders["X-Forwarded-Proto"]; + delete sendingHeaders["X-Forwarded-Host"]; + delete sendingHeaders["X-Forwarded-Port"]; + fetch(new URL(requestedURL, PANEL_CONFIG.GRAFANA_ORIGIN).href, { method, - headers: req.headers, + headers: sendingHeaders, body: method === "GET" ? undefined : req }) .then((grafanaResponse) => { res.statusCode = grafanaResponse.status; res.statusMessage = grafanaResponse.statusText; + for (const [name, value] of grafanaResponse.headers) res.setHeader(name, value); grafanaResponse.body.pipe(res);