diff --git a/APP_UI/.dockerignore b/APP_UI/.dockerignore new file mode 100644 index 0000000..bbedb18 --- /dev/null +++ b/APP_UI/.dockerignore @@ -0,0 +1,6 @@ +node_modules +dist +.vscode +.git +*.bak +*.log diff --git a/APP_UI/Dockerfile b/APP_UI/Dockerfile index a52aedb..d6e3856 100644 --- a/APP_UI/Dockerfile +++ b/APP_UI/Dockerfile @@ -2,14 +2,15 @@ FROM node:20-alpine AS build-stage WORKDIR /app COPY package*.json ./ -RUN npm install +RUN npm ci COPY . . RUN npm run build # Stage 2: Serve +# nginx runs as root here: the image entrypoint renders the template into /etc/nginx/conf.d and port 80 +# is published by docker-compose. An unprivileged variant would change the port and the image. FROM nginx:alpine COPY --from=build-stage /app/dist /usr/share/nginx/html COPY default.conf.template /etc/nginx/templates/default.conf.template EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] - diff --git a/APP_UI/default.conf.template b/APP_UI/default.conf.template index 196e76d..d6c5513 100644 --- a/APP_UI/default.conf.template +++ b/APP_UI/default.conf.template @@ -1,21 +1,54 @@ server { listen 80; server_name localhost; + server_tokens off; root /usr/share/nginx/html; index index.html; + # Security headers. add_header in a location replaces the ones inherited from the server block, + # so the /assets/ location below repeats them. CSP: the bundle is served from this origin only; + # style-src 'unsafe-inline' is needed by Bootstrap and Chart.js (inline style attributes); + # connect-src 'self' means config.json must point to proxied paths (the defaults /api/v1 and /profiles-api). + add_header X-Content-Type-Options "nosniff" always; + add_header X-Frame-Options "DENY" always; + add_header Referrer-Policy "no-referrer" always; + add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always; + + gzip on; + gzip_vary on; + gzip_min_length 1024; + gzip_types text/plain text/css text/javascript application/javascript application/json image/svg+xml; + location / { try_files $uri $uri/ /index.html; } + # Hashed build files never change under the same name + location /assets/ { + try_files $uri =404; + add_header Cache-Control "public, max-age=31536000, immutable"; + add_header X-Content-Type-Options "nosniff" always; + add_header X-Frame-Options "DENY" always; + add_header Referrer-Policy "no-referrer" always; + add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always; + } + + # The entry page and the runtime configuration must be revalidated after an update + # (expires -1 sends "Cache-Control: no-cache" and keeps the server-level headers) + location = /index.html { + expires -1; + } + location = /config.json { + expires -1; + } + # Модуль 1: Мониторинг (Flask, порт 5001) location /api/ { proxy_pass http://${OVP_API_HOST}:${OVP_API_PORT}; 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_pass_header Authorization; } # Модуль 2: Управление профилями (FastAPI, порт 8000) @@ -34,4 +67,4 @@ server { location = /50x.html { root /usr/share/nginx/html; } -} \ No newline at end of file +} diff --git a/APP_UI/src/components/ProfileDetailsModal.vue b/APP_UI/src/components/ProfileDetailsModal.vue index 334d261..dbee46c 100644 --- a/APP_UI/src/components/ProfileDetailsModal.vue +++ b/APP_UI/src/components/ProfileDetailsModal.vue @@ -3,7 +3,7 @@ {{ profile?.username }} - {{ status.label }} + @@ -36,6 +36,7 @@ diff --git a/APP_UI/src/views/Certificates.vue b/APP_UI/src/views/Certificates.vue index 89c3d8e..d2c33df 100644 --- a/APP_UI/src/views/Certificates.vue +++ b/APP_UI/src/views/Certificates.vue @@ -102,7 +102,7 @@ {{ cert.days_remaining }} - + @@ -131,7 +131,7 @@ {{ cert.days_remaining }} - + @@ -156,6 +156,7 @@ import { useApi } from '../composables/useApi'; import NewClientModal from '../components/NewClientModal.vue'; import ConfirmModal from '../components/ConfirmModal.vue'; import ProfileDetailsModal from '../components/ProfileDetailsModal.vue'; +import StatusBadge from '../components/StatusBadge.vue'; import vNoteTooltip from '../directives/noteTooltip'; import { useToast } from '../composables/useToast'; import { usePkiStatus } from '../composables/usePkiStatus'; @@ -190,23 +191,6 @@ const getDaysClass = (days) => { return 'text-success'; }; -const getStatusBadgeHTML = (cert) => { - if (cert.is_revoked) { - return 'Revoked'; - } - if (cert.is_expired) { - return 'Expired'; - } - - // Days check logic for expiring soon warning - if (cert.days_remaining !== null && cert.days_remaining <= 30) { - return 'Expiring Soon'; - } - - return 'Active'; -}; - - // Data Processing const filteredData = computed(() => { let data = allProfiles.value;