# Apache 2.4 on Ubuntu: static front end for mamsv2.nafith.om, backend forwarded to mamsbe.nafith.om.
# sudo a2enmod proxy proxy_http ssl rewrite headers deflate expires
# copy this file to /etc/apache2/sites-available/mamsv2.conf, fix the certificate paths, then:
# sudo a2ensite mamsv2 && sudo apache2ctl configtest && sudo systemctl reload apache2
# build: npm run build (reads .env.production) then copy dist/* to /var/www/mamsv2/
ServerName mamsv2.nafith.om
DocumentRoot /var/www/mamsv2
SSLEngine on
SSLCertificateFile /etc/ssl/certs/mamsv2.crt
SSLCertificateKeyFile /etc/ssl/private/mamsv2.key
# --- backend: /api on this host is the root of https://mamsbe.nafith.om ---
SSLProxyEngine on
SSLProxyCheckPeerName on
ProxyPreserveHost Off
# login and large exports can take 15 s or more
ProxyTimeout 180
ProxyPass /api/ https://mamsbe.nafith.om/
ProxyPassReverse /api/ https://mamsbe.nafith.om/
ProxyPassReverseCookieDomain mamsbe.nafith.om mamsv2.nafith.om
# attachment uploads: 50 MB, match the backend's own limit
LimitRequestBody 52428800
# --- single-page app: any unknown path serves index.html ---
Require all granted
Options -Indexes
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/api/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.html [L]
# --- caching: hashed assets forever, index.html never ---
Header set Cache-Control "public, max-age=31536000, immutable"
Header set Cache-Control "no-cache"
# --- security headers (a Content-Security-Policy is left for the security team: fonts and reCAPTCHA load from Google) ---
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set Referrer-Policy "same-origin"
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
Header always set Permissions-Policy "geolocation=(), camera=(), microphone=()"
Header always unset X-Powered-By
ServerName mamsv2.nafith.om
Redirect permanent / https://mamsv2.nafith.om/