Speculare
Search…
⌃K
Links

Nginx config

Install dependencies

We recommend you to use NodeJS 15+.
# Install nginx
sudo apt install -y nginx

Sample nginx config

You can just create a new sites within nginx. In /etc/nginx/sites-available/dashboard:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name dashboard.speculare.cloud;
root /root/speculare-dashboard/dist_current;
# SSL
ssl_certificate /etc/letsencrypt/live/dashboard.speculare.cloud/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dashboard.speculare.cloud/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/dashboard.speculare.cloud/chain.pem;
# security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "connect-src wss://cdc.speculare.cloud https://server.speculare.cloud";
# . files
location ~ /\.(?!well-known) {
deny all;
}
# additional config
include nginxconfig.io/general.conf;
location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ {
access_log off;
expires 30d;
}
location ~* ^.+\.(css|js|txt|xml|swf|wav)$ {
access_log off;
expires 24h;
}
location ~* ^.+\.(html|htm)$ {
expires 1h;
}
location ~* ^.+\.(eot|ttf|otf|woff|svg)$ {
access_log off;
expires max;
}
location / {
try_files $uri /index.html;
}
}
# HTTP redirect
server {
listen 80;
listen [::]:80;
server_name dashboard.speculare.cloud;
location / {
return 301 https://dashboard.speculare.cloud$request_uri;
}
}
Don't forget to update the domains and SSL paths.
The above config rely on /etc/nginx/nginxconfig.io/general.conffor caching & robots instructions:
# favicon.ico
location = /favicon.ico {
log_not_found off;
access_log off;
}
# robots.txt
location = /robots.txt {
log_not_found off;
access_log off;
}
# assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
expires 7d;
access_log off;
}
# svg, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
add_header Access-Control-Allow-Origin "*";
expires 7d;
access_log off;
}
# gzip
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;