<VirtualHost *:80>
ServerName penguins-eggs.net
ServerAlias penguins-eggs.net
ServerAdmin piero.proietti@gmail.com
# Rewrite any http traffic to the main url https site
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^[^\/]*\/(.*) https://penguins-eggs.net/$1 [R=301,L]
</IfModule>
</VirtualHost>
<VirtualHost *:443>
Protocols h2 http/1.1
ServerName penguins-eggs.net
SSLEngine on
# This directory contains your keys and certificates.
# `privkey.pem` : the private key for your certificate.
# `fullchain.pem`: the certificate file used in most server software.
# `chain.pem` : used for OCSP stapling in Nginx >=1.3.7.
#`cert.pem` : will break many server configurations, and should not be used
# without reading further documentation (see link below).
SSLCertificateFile /etc/letsencrypt/live/penguins-eggs.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/penguins-eggs.net/privkey.pem
# certificati fatti a mano
#SSLCertificateFile /etc/ssl/certs/penguins-eggs-certificate.crt
#SSLCertificateKeyFile /etc/ssl/private/penguins-eggs.key
# Basic security headers
Header always set X-Content-Type-Options "nosniff"
Header always set X-Xss-Protection "1; mode=block"
# NodeBB header
RequestHeader set X-Forwarded-Proto "https"
# Static file cache
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css)$">
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 14 days"
Header set Cache-Control "public"
</IfModule>
</FilesMatch>
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
# Custom Error Document when NodeBB is offline
ProxyPass /error-documents !
ErrorDocument 503 /error-documents/503.html
Alias /error-documents /path/to/nodebb/public
# Websocket passthrough
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:4567/$1 [P,L]
# forum
ProxyPass /forum/ http://127.0.0.1:4567/forum/
ProxyPassReverse /forum/ http://127.0.0.1:4567/forum/
# blog
ProxyPass / http://127.0.0.1:4000/
ProxyPassReverse / http://127.0.0.1:4000/
# Log stuff
ErrorLog ${APACHE_LOG_DIR}/blog_error.log
CustomLog ${APACHE_LOG_DIR}/blog_access.log combined
</VirtualHost>