Instalace
NGINX
- příklad konfigurace pro server Nginx
user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 768; # multi_accept on; } http { ## # Základní nastavení ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; ## # SSL nastavení ## ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Vypnutí SSLv3, viz POODLE ssl_prefer_server_ciphers on; ## # Logování ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip komprese ## gzip on; ## Poznámka: máme velmi velká těla požadavků client_body_buffer_size 500M; client_max_body_size 250M; # Vypnutí logování na úrovni serveru access_log off; # Bezpečnost server_tokens off; more_clear_headers Server; error_page 301 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 /error.html; # https://www.nginx.com/blog/avoiding-top-10-nginx-configuration-mistakes/#upstream-groups upstream api_scada { zone upstreams 64K; server scada_server:8520; keepalive 2; } log_format upstream_time '$remote_addr [$time_local] ' '"$request" $status $body_bytes_sent gzipRatio=$gzip_ratio ' 'request_time=$request_time up_response_time="$upstream_response_time"'; log_format grpc_format '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent"'; ####################################### 80 server { listen 80; listen [::]:80; server_name _; index index.html index.php; root /mnt/bigdata/cfg/mervis_nginx/www; ## staré API u project-storage vyžaduje "." v hlavičce... #ignore_invalid_headers off; gzip on; gzip_types text/plain; gzip_proxied no-cache no-store private expired auth; gzip_min_length 1000; # Bezpečnostní hlavičky add_header X-Content-Type-Options nosniff; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload" always; add_header X-Frame-Options "SAMEORIGIN"; add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' *.tile.openstreetmap.org data:; frame-src kb.mervis.info; object-src 'none';" always; location = /error.html { ssi on; internal; auth_basic off; root /mnt/bigdata/cfg/mervis_nginx/www/errors/; } # pro certbot SSL location /.well-known/acme-challenge { alias /mnt/bigdata/cfg/mervis_nginx/www/.well-known/acme-challenge; } # přesměrování všeho na HTTPS location / { return 301 https://$host$request_uri; } location ~ /(\.svn|web.config) { deny all; } } ######################################### 443 # Bezpečnostní server - pro neznámé domény server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name ""; ssl_certificate /etc/letsencrypt/live/scada.domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/scada.domain.com/privkey.pem; # Kód 444 uzavírá spojení bez odeslání hlaviček return 444; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name scada.domain.com; index index.html; root /mnt/bigdata/cfg/mervis_nginx/www; ssl_certificate /etc/letsencrypt/live/scada.domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/scada.domain.com/privkey.pem; ssl_session_timeout 1d; ssl_session_cache shared:SSL:50m; ssl_session_tickets off; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; #ssl_dhparam /etc/ssl/dhparam.pem; ssl_stapling on; ssl_stapling_verify on; gzip on; gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/json application/xml application/rss+xml image/svg+xml; gzip_proxied no-cache no-store private expired auth; gzip_min_length 1000; # Bezpečnostní hlavičky add_header X-Content-Type-Options nosniff; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload" always; add_header X-Frame-Options "SAMEORIGIN"; location = /error.html { ssi on; internal; auth_basic off; root /mnt/bigdata/cfg/scada.domain.com/www; } location = /index.html { add_header Cache-Control "no-cache, public, must-revalidate, proxy-revalidate"; add_header X-Content-Type-Options nosniff; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload" always; add_header X-Frame-Options "SAMEORIGIN"; add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' *.tile.openstreetmap.org data:; frame-src kb.mervis.info; object-src 'none';" always; } location / { try_files $uri $uri/ =404; # vše je kešováno na 1 hodinu a následně obnovováno na pozadí po dobu 1 měsíce location ~* \.(js|css|png|jpg|jpeg|gif|svg|ico)$ { add_header Cache-Control "public, no-transform, max-age=3600, stale-while-revalidate=2592000"; add_header X-Content-Type-Options nosniff; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload" always; add_header X-Frame-Options "SAMEORIGIN"; add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' *.tile.openstreetmap.org data:; frame-src kb.mervis.info; object-src 'none';" always; } } location /api-scada { proxy_http_version 1.1; proxy_set_header "Connection" ""; proxy_pass http://api_scada/api; add_header X-Content-Type-Options nosniff; proxy_hide_header x-powered-by; proxy_hide_header x-aspnet-version; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload" always; add_header X-Frame-Options "SAMEORIGIN"; add_header Cache-Control "no-store"; add_header Pragma "no-cache"; add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' *.tile.openstreetmap.org data:; frame-src kb.mervis.info; object-src 'none';" always; } location ~ /(\.svn|web.config) { deny all; } } }
Error.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Mervis</title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <h1>Chyba: <!--# echo var="status" default="" --></h1> </body>
Cloud Interface
Cloud Interface potřebuje v rámci OS Windows přístupová práva ke čtení informací z Performace Couters. Pomocí příkazového řádku to lze provést následovně:
net localgroup „Performance Monitor Users“ DefaultAppPool /add
net localgroup „Performance Log Users“ DefaultAppPool /add
tím se účet, pod kterým se spouští aplikační pool IIS s Cloud Interface (tj. účet DefaultAppPool), přidá do skupin, které potřebné právo mají. Pro uživatelsky vytvořený pool s názvem XY vytváří IIS virtualního uživatele s názvem „IIS APPPOOL\XY“.
Pokud výše uvedený postup nebude fungovat, je možné změnit identitu poolu z ApplicationPoolIdentity na LocalService.