备份一些配置文件
首先安装依赖 fcgiwrap,修改或者创建这些文件:
/etc/smokeping/config.d/Probes
*** Probes ***
+ FPing
binary = /usr/bin/fping
+ FPing6
binary = /usr/bin/fping6 # mandatory
#blazemode = true
#hostinterval = 1.5
#mininterval = 0.001
#offset = 50%
#packetsize = 5000
#pings = 20
#sourceaddress = ::1
#step = 300
#timeout = 1.5
#tos = 0x20
#usestdout = true
+ Curl
binary = /usr/bin/curl
urlformat = http://%host%/ # mandatory
pings = 3
/etc/smokeping/config.d/Targets
*** Targets ***
probe = FPing6
menu = Top
title = Network Latency Grapher
remark = Welcome. Here we monitor the network \
latency connecting to google.com.
+ google
probe = FPing6
menu = Google
title = Hosts of Google
host = google.com
+ baidu
probe = Curl
menu = Baidu
title = Hosts of Baidu
host = baidu.com
/etc/nginx/sites_available/smokeping.example.com
# got this file from https://github.com/vazhnov/smokeping_nginx, slightly modified.
# Start page: http://smokeping.example.com/
server {
listen 80;
listen [::]:80;
server_name smokeping.example.com;
auth_basic "Restricted Area";
auth_basic_user_file /path/to/htpasswd;
location = /smokeping/smokeping.cgi {
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/smokeping.cgi;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location ^~ /smokeping/ {
alias /usr/share/smokeping/www/;
index smokeping.cgi;
gzip off;
}
location / {
return 301 http://$server_name/smokeping/smokeping.cgi;
}
}
完成之后,
systemctl restart smokeping.service
sudo nginx -s reload
在80端口下测试正常之后,购买一个证书,然后稍微修改 nginx 配置文件换到 ssl。删除之前的内容,添加如下内容
/etc/nginx/sites_available/smokeping.example.com
server {
listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate /path/to/pem
ssl_certificate_key /path/to/pem
include /path/to/sslconfig
ssl_dhparam /path/to/pem
server_name smokeping.example.com;
auth_basic "Restricted Area";
auth_basic_user_file /path/to/htpasswd;
location = /smokeping/smokeping.cgi {
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/smokeping.cgi;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location ^~ /smokeping/ {
alias /usr/share/smokeping/www/;
index smokeping.cgi;
gzip off;
}
location / {
return 301 http://$server_name/smokeping/smokeping.cgi;
}
}