59 lines
2.3 KiB
Plaintext
59 lines
2.3 KiB
Plaintext
# 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/
|
|
|
|
<VirtualHost *:443>
|
|
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 ---
|
|
<Directory /var/www/mamsv2>
|
|
Require all granted
|
|
Options -Indexes
|
|
RewriteEngine On
|
|
RewriteCond %{REQUEST_URI} !^/api/
|
|
RewriteCond %{REQUEST_FILENAME} !-f
|
|
RewriteCond %{REQUEST_FILENAME} !-d
|
|
RewriteRule ^ /index.html [L]
|
|
</Directory>
|
|
|
|
# --- caching: hashed assets forever, index.html never ---
|
|
<Location /assets/>
|
|
Header set Cache-Control "public, max-age=31536000, immutable"
|
|
</Location>
|
|
<Files "index.html">
|
|
Header set Cache-Control "no-cache"
|
|
</Files>
|
|
|
|
# --- 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
|
|
</VirtualHost>
|
|
|
|
<VirtualHost *:80>
|
|
ServerName mamsv2.nafith.om
|
|
Redirect permanent / https://mamsv2.nafith.om/
|
|
</VirtualHost>
|