Skip to content

Instantly share code, notes, and snippets.

@djvdorp
Created October 31, 2016 06:34
Show Gist options
  • Save djvdorp/87ffdd1160578aad03be69f4c98b390f to your computer and use it in GitHub Desktop.
Save djvdorp/87ffdd1160578aad03be69f4c98b390f to your computer and use it in GitHub Desktop.
LibreNMS /etc/nginx/sites-enabled/librenms.example.com.conf for nginx using TLS and HTTP2 by default
server {
listen 80 default_server;
listen [::]:80 default_server;
# Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/nginx/ssl/librenms.example.com.chain.cer;
ssl_certificate_key /etc/nginx/ssl/librenms.example.com.key;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_dhparam /etc/nginx/dhparam.pem;
ssl_protocols TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
server_name librenms.example.com;
root /opt/librenms/html;
access_log /opt/librenms/logs/access_log;
error_log /opt/librenms/logs/error_log;
index index.php;
location / {
try_files $uri $uri/ @librenms;
}
location ~ \.php {
fastcgi_keep_conn on;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location @librenms {
rewrite api/v0(.*)$ /api_v0.php/$1 last;
rewrite ^(.+)$ /index.php/$1 last;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment