<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.apoyar.eu/index.php?action=history&amp;feed=atom&amp;title=Certificate_checks_on_Nagios</id>
	<title>Certificate checks on Nagios - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.apoyar.eu/index.php?action=history&amp;feed=atom&amp;title=Certificate_checks_on_Nagios"/>
	<link rel="alternate" type="text/html" href="https://wiki.apoyar.eu/index.php?title=Certificate_checks_on_Nagios&amp;action=history"/>
	<updated>2026-07-20T14:31:55Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.apoyar.eu/index.php?title=Certificate_checks_on_Nagios&amp;diff=189&amp;oldid=prev</id>
		<title>Admin: Created page with &quot;Certificate Checks on Nagios -------------------------------  There two kind of certificates  1) Commercial – Expiry alert 30 days before  2) Letsencrypt - Expiry alert 10 d...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.apoyar.eu/index.php?title=Certificate_checks_on_Nagios&amp;diff=189&amp;oldid=prev"/>
		<updated>2021-06-30T11:20:00Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Certificate Checks on Nagios -------------------------------  There two kind of certificates  1) Commercial – Expiry alert 30 days before  2) Letsencrypt - Expiry alert 10 d...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Certificate Checks on Nagios&lt;br /&gt;
-------------------------------&lt;br /&gt;
&lt;br /&gt;
There two kind of certificates&lt;br /&gt;
&lt;br /&gt;
1) Commercial – Expiry alert 30 days before&lt;br /&gt;
&lt;br /&gt;
2) Letsencrypt - Expiry alert 10 days before&lt;br /&gt;
&lt;br /&gt;
To check and configure certificate alert in nagios &lt;br /&gt;
&lt;br /&gt;
Login to nagios.apoyar&lt;br /&gt;
&lt;br /&gt;
•	cd /  usr/local/etc/nagios/objects/&lt;br /&gt;
&lt;br /&gt;
•	vi wwwservices.cfg&lt;br /&gt;
&lt;br /&gt;
here will see two paragraph’s, first one is for commercial certificates and other one is for letsecrypt certificates&lt;br /&gt;
&lt;br /&gt;
add the server name under either commercial or letsencrypt in hostname&lt;br /&gt;
&lt;br /&gt;
and save the file (:wq!)&lt;br /&gt;
&lt;br /&gt;
Run below command for syntax error check&lt;br /&gt;
&lt;br /&gt;
•	/usr/local/bin/nagios -v /usr/local/etc/nagios/nagios.cfg&lt;br /&gt;
&lt;br /&gt;
And at last restart Nagios process fom nagios.apoyar.net&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Upgrading Nginx&lt;br /&gt;
---------------------------&lt;br /&gt;
&lt;br /&gt;
Login to server, on which need to upgrade nginx&lt;br /&gt;
&lt;br /&gt;
Go to&lt;br /&gt;
&lt;br /&gt;
•	cd /root&lt;br /&gt;
&lt;br /&gt;
Download latest nginx file with below command&lt;br /&gt;
&lt;br /&gt;
•	wget  http://nginx.org/download/nginx-1.20.1.tar.gz&lt;br /&gt;
&lt;br /&gt;
unzip this file with below command&lt;br /&gt;
&lt;br /&gt;
•	tar xzvf nginx-1.20.1.tar.gz&lt;br /&gt;
&lt;br /&gt;
then, go to below path and download openssl file&lt;br /&gt;
&lt;br /&gt;
•	cd /usr/local/src/&lt;br /&gt;
&lt;br /&gt;
•	wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz&lt;br /&gt;
&lt;br /&gt;
unzip this file with below command&lt;br /&gt;
&lt;br /&gt;
•	tar xzvf openssl-1.1.1k.tar.gz&lt;br /&gt;
&lt;br /&gt;
After this, go to&lt;br /&gt;
&lt;br /&gt;
•	cd /root/nginx-1.20.1&lt;br /&gt;
&lt;br /&gt;
•	nginx –V&lt;br /&gt;
&lt;br /&gt;
•	copy all options to compile nginx&lt;br /&gt;
&lt;br /&gt;
•	./config  paste that options here and hit enter&lt;br /&gt;
&lt;br /&gt;
Then at last below command, this will run the actual compilation&lt;br /&gt;
&lt;br /&gt;
•	Make&lt;br /&gt;
&lt;br /&gt;
To check certificates on phobos.apoyar&lt;br /&gt;
&lt;br /&gt;
Login to phobos.apoyar&lt;br /&gt;
&lt;br /&gt;
•	cd certs/generated/&lt;br /&gt;
&lt;br /&gt;
Here we can see all certificates generated before&lt;br /&gt;
&lt;br /&gt;
- firewall suffix certificates are IPsec ones&lt;br /&gt;
&lt;br /&gt;
- other than that for us or our customers&lt;br /&gt;
&lt;br /&gt;
If you look into Apoyar certificates, go to Apoyar folder&lt;br /&gt;
&lt;br /&gt;
•	cd Apoyar&lt;br /&gt;
&lt;br /&gt;
•	ls&lt;br /&gt;
&lt;br /&gt;
here will find .crt file Apoyar key .. to check if that both identical and from issuer or not.. run below command&lt;br /&gt;
&lt;br /&gt;
•	openssl x509 -noout -modulus -in apoyar2021.crt | openssl md5 &amp;amp;&amp;amp; openssl rsa -noout -modulus -in www.apoyar.eu.key | openssl md5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And if we have to concatenate two certificate files into single certificate, then use below command for that&lt;br /&gt;
&lt;br /&gt;
cat test.crt | awk -v cmd=&amp;quot;openssl x509 -subject -issuer -noout&amp;quot; &amp;#039;/-----BEGIN/ { c = $0; next } c { c = c &amp;quot;\n&amp;quot; $0 } /-----END/ { print c|cmd; close(cmd); c = 0 }&amp;#039;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nginx Compilation on New Server&lt;br /&gt;
-----------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Build NGINX from source&lt;br /&gt;
&lt;br /&gt;
1.	NGINX is a program written in C, so we need to install the C compiler (GCC).&lt;br /&gt;
&lt;br /&gt;
sudo apt install build-essential –y&lt;br /&gt;
&lt;br /&gt;
2.	Download the latest version of NGINX source code and extract it: &lt;br /&gt;
&lt;br /&gt;
wget https://nginx.org/download/nginx-1.13.1.tar.gz &amp;amp;&amp;amp; tar zxvf nginx-1.13.1.tar.gzGo to the NGINX source directory:&lt;br /&gt;
cd ~/nginx-1.13.1&lt;br /&gt;
&lt;br /&gt;
3.	On the current running Nginx, determine the current configure settings:&lt;br /&gt;
&lt;br /&gt;
nginx -V&lt;br /&gt;
&lt;br /&gt;
And the current location to the nginx executable:&lt;br /&gt;
&lt;br /&gt;
which nginx&lt;br /&gt;
&lt;br /&gt;
Then copy and paste the results to a text file&lt;br /&gt;
&lt;br /&gt;
4.	Configure, compile, back up and remove the old and install new NGINX:&lt;br /&gt;
&lt;br /&gt;
./configure --with &amp;lt;whatever the above command gave you&amp;gt; --with &amp;lt;additional parameters you want to add&amp;gt;&lt;br /&gt;
The additional parameters could be --with-http_secure_link_module or any other additional modules.&lt;br /&gt;
cd /&lt;br /&gt;
&lt;br /&gt;
tar czvf nginx.tar.gz /etc/nginx/&lt;br /&gt;
&lt;br /&gt;
dpkg -l | grep nginx&lt;br /&gt;
&lt;br /&gt;
apt-get purge &amp;lt;all packages the above command has found&amp;gt;&lt;br /&gt;
&lt;br /&gt;
make &lt;br /&gt;
&lt;br /&gt;
sudo make install&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5.	If the ./configure gives you any errors, take the following steps:&lt;br /&gt;
&lt;br /&gt;
apt-get install uuid-dev&lt;br /&gt;
&lt;br /&gt;
If ./configure gives you an error about psol not found&lt;br /&gt;
 &lt;br /&gt;
apt-get install libgd-dev in case of this error:&lt;br /&gt;
&lt;br /&gt;
 ./configure: error: the HTTP image filter module requires the GD library.&lt;br /&gt;
&lt;br /&gt;
If there is an issue with the package installation after upgrading to Ubuntu 18, just uninstall the dependencies, and reinstall all packages this uninstall has removed&lt;br /&gt;
 &lt;br /&gt;
apt-get install libgeoip-dev in case of:&lt;br /&gt;
&lt;br /&gt;
 ./configure: error: the GeoIP module requires the GeoIP library.&lt;br /&gt;
 &lt;br /&gt;
install libssl-dev in case of:&lt;br /&gt;
&lt;br /&gt;
 ./configure: error: SSL modules require the OpenSSL library.&lt;br /&gt;
 &lt;br /&gt;
apt-get install libpcre++-dev in case of:&lt;br /&gt;
&lt;br /&gt;
 ./configure: error: the HTTP rewrite module requires the PCRE library.&lt;br /&gt;
&lt;br /&gt;
If the above doesn&amp;#039;t work (spotted on Ubuntu 18):&lt;br /&gt;
&lt;br /&gt;
add-apt-repository ppa:ondrej/php&lt;br /&gt;
&lt;br /&gt;
apt-get install libpcre3 libpcre3-dev&lt;br /&gt;
 &lt;br /&gt;
apt-get install libxslt1-dev in case of:&lt;br /&gt;
&lt;br /&gt;
 ./configure: error: the HTTP XSLT module requires the libxml2/libxslt&lt;br /&gt;
 &lt;br /&gt;
apt-get install zlib1g-dev&lt;br /&gt;
&lt;br /&gt;
./configure: error: the HTTP gzip module requires the zlib library&lt;br /&gt;
 &lt;br /&gt;
apt-get install libpam0g-dev in case of:&lt;br /&gt;
&lt;br /&gt;
make gives you an error:&lt;br /&gt;
&lt;br /&gt;
fatal error: security/pam_appl.h: No such file or directory&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
6.	If make gives you any errors:&lt;br /&gt;
&lt;br /&gt;
apt-get install libpam0g-dev in case of:&lt;br /&gt;
&lt;br /&gt;
recipe for target &amp;#039;objs/addon/ngx_http_auth_pam_module/ngx_http_auth_pam_module.o&amp;#039; failed&lt;br /&gt;
 &lt;br /&gt;
apt-get install libperl-dev in case of:&lt;br /&gt;
&lt;br /&gt;
cannot find –lperl&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
7.	Remove all downloaded files from the home directory, in this case /home/username:&lt;br /&gt;
&lt;br /&gt;
cd ~&lt;br /&gt;
&lt;br /&gt;
rm -r nginx-1.13.1/ openssl-1.1.0f/ pcre-8.40/ zlib-1.2.11/&lt;br /&gt;
&lt;br /&gt;
8.	Check NGINX version and compile time options &lt;br /&gt;
&lt;br /&gt;
If the nginx command doesn&amp;#039;t work, create a symlink:&lt;br /&gt;
&lt;br /&gt;
ln -s /usr/share/nginx/sbin/nginx /usr/sbin/&lt;br /&gt;
&lt;br /&gt;
sudo nginx -v &amp;amp;&amp;amp; sudo nginx -V&lt;br /&gt;
&lt;br /&gt;
# nginx version: nginx/1.13.0 (Ubuntu)&lt;br /&gt;
&lt;br /&gt;
# built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)&lt;br /&gt;
&lt;br /&gt;
# built with OpenSSL 1.1.0f  25 May 2017&lt;br /&gt;
&lt;br /&gt;
# TLS SNI support enabled&lt;br /&gt;
&lt;br /&gt;
# configure arguments: --prefix=/etc/nginx . . .&lt;br /&gt;
&lt;br /&gt;
# . . .&lt;br /&gt;
&lt;br /&gt;
# . . .&lt;br /&gt;
&lt;br /&gt;
9.	Check syntax and potential errors:&lt;br /&gt;
&lt;br /&gt;
sudo nginx -t&lt;br /&gt;
&lt;br /&gt;
# Will throw this error nginx: [emerg] mkdir() &amp;quot;/var/lib/nginx/body&amp;quot; failed (2: No such file or directory)&lt;br /&gt;
&lt;br /&gt;
# Just create directory&lt;br /&gt;
&lt;br /&gt;
mkdir -p /var/lib/nginx &amp;amp;&amp;amp; sudo nginx –t&lt;br /&gt;
&lt;br /&gt;
10.	Create systemd unit file for NGINX:&lt;br /&gt;
&lt;br /&gt;
sudo vim /etc/systemd/system/nginx.service&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
11.	Copy/paste the following content:&lt;br /&gt;
&lt;br /&gt;
NOTE: The location of the PID file and the NGINX binary may be different depending on how NGINX was compiled.&lt;br /&gt;
&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=A high performance web server and a reverse proxy server&lt;br /&gt;
After=network.target&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=forking&lt;br /&gt;
PIDFile=/run/nginx.pid&lt;br /&gt;
ExecStartPre=/usr/sbin/nginx -t -q -g &amp;#039;daemon on; master_process on;&amp;#039;&lt;br /&gt;
ExecStart=/usr/sbin/nginx -g &amp;#039;daemon on; master_process on;&amp;#039;&lt;br /&gt;
ExecReload=/usr/sbin/nginx -g &amp;#039;daemon on; master_process on;&amp;#039; -s reload&lt;br /&gt;
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid&lt;br /&gt;
TimeoutStopSec=5&lt;br /&gt;
KillMode=mixed&lt;br /&gt;
&lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=multi-user.target&lt;br /&gt;
&lt;br /&gt;
12.	Start and enable NGINX service:&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start nginx.service &amp;amp;&amp;amp; sudo systemctl enable nginx.service&lt;br /&gt;
&lt;br /&gt;
13.	Check if NGINX will startup after a reboot:&lt;br /&gt;
&lt;br /&gt;
sudo systemctl is-enabled nginx.service&lt;br /&gt;
&lt;br /&gt;
# enabled&lt;br /&gt;
&lt;br /&gt;
14.	Check if NGINX is running:&lt;br /&gt;
&lt;br /&gt;
sudo systemctl status nginx.service&lt;br /&gt;
&lt;br /&gt;
ps aux | grep nginx&lt;br /&gt;
&lt;br /&gt;
curl -I 127.0.0.1&lt;br /&gt;
&lt;br /&gt;
15.	Reboot your Ubuntu VPS to verify that NGINX starts up automatically:&lt;br /&gt;
&lt;br /&gt;
sudo shutdown -r now&lt;br /&gt;
&lt;br /&gt;
16.	Create UFW NGINX application profile:&lt;br /&gt;
&lt;br /&gt;
sudo vim /etc/ufw/applications.d/nginx&lt;br /&gt;
&lt;br /&gt;
17.	Copy/paste the following content:&lt;br /&gt;
&lt;br /&gt;
[Nginx HTTP]&lt;br /&gt;
title=Web Server (Nginx, HTTP)&lt;br /&gt;
description=Small, but very powerful and efficient web server&lt;br /&gt;
ports=80/tcp&lt;br /&gt;
&lt;br /&gt;
[Nginx HTTPS]&lt;br /&gt;
title=Web Server (Nginx, HTTPS)&lt;br /&gt;
description=Small, but very powerful and efficient web server&lt;br /&gt;
ports=443/tcp&lt;br /&gt;
&lt;br /&gt;
[Nginx Full]&lt;br /&gt;
title=Web Server (Nginx, HTTP + HTTPS)&lt;br /&gt;
description=Small, but very powerful and efficient web server&lt;br /&gt;
ports=80,443/tcp&lt;br /&gt;
&lt;br /&gt;
18.	Now, verify that UFW app profiles are created and recognized:&lt;br /&gt;
&lt;br /&gt;
sudo ufw app list&lt;br /&gt;
&lt;br /&gt;
# Available applications:&lt;br /&gt;
&lt;br /&gt;
  # Nginx Full&lt;br /&gt;
&lt;br /&gt;
  # Nginx HTTP&lt;br /&gt;
&lt;br /&gt;
  # Nginx HTTPS&lt;br /&gt;
&lt;br /&gt;
  # OpenSSH&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>