- Candle Graph
- Line Grap
- Ohlc Graph
In this blog you can find technical matter related to information security. Other than that Linux server configuration, Nginx configuration, high availability techniques etc...
Saturday, July 9, 2022
How to Draw Graph for Stocks (Python)
How to Restrict Request Method in NGINX
HTTP and HTTPS protocol has several request methods. POST, GET, PUT, PATCH, HEAD and DELETE. When we configuraing NGINX web server we need to restrict PUT,PATCH and DELETE request methods. Only POST, GET and HEAD methods enough to enable from web sever.
Configurations
How to Install Your Own CA Certificate to Linux Server
Requirement
Step 01: Copy your CA certificate to "/usr/local/share/ca-certificates/"
Step: 02: update-ca-certificates
# update-ca-certificatesStep 03: update-ca-certificates --fresh
How to configure Go-access Real-time HTML Outputs (NGINX)
Requirement
GoAccess has the ability the output real-time data in the HTML report. You can even email the HTML file since it is composed of a single file with no external file dependencies, how neat is that!
The process of generating a real-time HTML report is very similar to the process of creating a static report. Only --real-time-html is needed to make it real-time.
Pre-Requisites
- NGINX web server which support websocket
- Install goaccess on the same server
Step 01: Configure NGINX proxy pass for goaccess real-time push
location /ws-goaccess {proxy_pass http://127.0.0.1:9870;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}
In my case Go-Access websocket port listen locally with port 9870.
Step 02: Identify log format of your NGINX web server
I used this GitHum repository to find out log format for goaccess.
URL: https://github.com/stockrt/nginx2goaccess
Command Usage
Usage: ./nginx2goaccess.sh '<log_format>'
NGINX log format u have to get from your web server. It should be in nginx.conf file. Configuration parameter "log_format"
Step 03: Start the Go-Access WebSocket Server
goaccess /var/log/nginx/data.vidutech.org-access.log /var/log/nginx/www.vidutech.org-access.log --log-format='%h - %^ [%d:%t %^] "%r" "%b" "%R" "%u" "%^"' --date-format=%d/%b/%Y --time-format=%T -o /usr/share/nginx/html/goaccess.html --real-time-html --addr=127.0.0.1 --port=9870 --ws-url=data.vidutech.org/ws-goaccess
Command Explanation
We can pass several log files as input
- /var/log/nginx/data.vidutech.org-access.log
- /var/log/nginx/www.vidutech.org-access.log
- You can obtain it from Step 02
- Go-Access report should be save under nginx share location. This file should be accessible via browser with server name.
- Start server as real-time
- Listen address and port
How to Save Entire HTML Page as Image
Prerequisites
- Python3 package
- Selenium webdriver (pip3 install -U selenium, pip3 install webdriver-manager
Source Code
Execute
Sunday, June 26, 2022
How to get Intensity Histogram of an Image
This blog shows how to get intensity histogram of an image.
Libraries: OpenCV
How to install OpenCV
https://sltechgeekx.blogspot.com/2022/06/how-to-installing-opencv-from-source.html
How to Create a Project in Eclipse with OpenCV Libraries
https://sltechgeekx.blogspot.com/2022/06/how-to-convert-rgb-image-to-gray.html
Program Source Code
Program Output
Friday, June 24, 2022
Benchmark Your NGINX WEB Server
There are lots of commercial and open source tools to benchmark your web server. In this blog I and going to demonstrate benchmark your web server with CIS benchmark policies. Any one can freely download CIS documents.
CIS Download URL: https://www.cisecurity.org/benchmark/nginx
"The CIS Benchmarks are distributed free of charge in PDF format to propagate their worldwide use and adoption as user-originated, de facto standards. CIS Benchmarks are the only consensus-based, best-practice security configuration guides both developed and accepted by government, business, industry, and academia."
Download benchmark scrip: https://github.com/viduranga0006/nginx-benchmark
This is a bash shell script. You have to run it with supper user. Once you execute, you have to select relevant category. At the end it will list summary of benchmark results.
Thursday, June 16, 2022
How to Convert RGB Image to Gray
There are many many ways to convert RGB image to gray color. In this blog, I am wring a C++ code to do this.
Prerequisites
- Install OpenCV Libraries (https://sltechgeekx.blogspot.com/2022/06/how-to-installing-opencv-from-source.html)
- Eclipse C++ development application
Create New Project
Open Eclipse C/C++ and create a new C++ Project call “ConvertImageToGrayscale”
File -> New -> C++ Project
Include OpenCV Path
Right Click on the Project -> Properties -> C/C++ Build -> Settings -> Includes
Add opencv installed path
Include OpenCV Library Path
Include opencv libs to your project
Add New Source File
- Add new folder call “src” to project
- Right Click on the Project -> New -> Folder -> Enter the name
- Add Source file call “ConvertImageToGrayscale.cpp” to that “src” folder.
- Right Client on src folder -> New -> Source File -> Enter the Name
Source Code
/** ConvertImageToGrayscale.cpp** Created on: Jun 15, 2022* Author: viduranga*/#include <opencv2/opencv.hpp>#include <unistd.h>#ifndef __has_includestatic_assert(false, "__has_include not supported");#else# if __cplusplus >= 201703L && __has_include(<filesystem>)# include <filesystem>namespace fs = std::filesystem;# elif __has_include(<experimental/filesystem>)# include <experimental/filesystem>namespace fs = std::experimental::filesystem;# elif __has_include(<boost/filesystem.hpp>)# include <boost/filesystem.hpp>namespace fs = boost::filesystem;# endif#endifusing namespace cv;using fs::current_path;int main(int argc, char** argv){char* ImageFile = argv[1];Mat original_image; /* mat object for storing original_image */original_image = imread( ImageFile, IMREAD_COLOR ); /* read ImageFile */if( argc != 2 || !original_image.data ){printf( " No image data \n " );return -1;}char *cwd = get_current_dir_name(); /* Get Current working Directory */std::string CurrentWorkingDirectory(cwd);std::string InputFilePath(ImageFile);std::string input_filename = InputFilePath.substr(InputFilePath.find_last_of("/\\") + 1); /* Get Path of input file */std::string input_folder_path = InputFilePath.substr(0,InputFilePath.find_last_of("\\/")); /* Get Folder Path of input file */std::string OutputFile;if (input_filename != InputFilePath){OutputFile = input_folder_path.append("/greyImage-");}else {OutputFile = CurrentWorkingDirectory.append("/greyImage-");}OutputFile = OutputFile.append(input_filename);Mat gray_image; /* mat object for storing gray_image */cvtColor( original_image, gray_image, COLOR_BGR2GRAY ); /* convert image from color to gray */imwrite( OutputFile, gray_image );namedWindow( "Original Image", WINDOW_AUTOSIZE ); /* set window name for Original Image */namedWindow( "Gray Image", WINDOW_AUTOSIZE ); /* set window name Gray Image */imshow( "Original Image", original_image ); /* show window containing original_image */imshow( "Gray Image", gray_image ); /* show window containing gray_image */waitKey(0); /* to exit */return 0;}
Monday, June 13, 2022
How to Installing OpenCV from the Source
What is OpenCV
OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products.
Install the required dependencies
apt install build-essential cmake git pkg-config libgtk-3-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev gfortran openexr libatlas-base-dev python3-dev python3-numpy libtbb2 libtbb-dev libdc1394-22-dev
Clone the OpenCV’s and OpenCV contrib repositories
mkdir ~/opencv_build && cd ~/opencv_build
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
Once the download is complete, create a temporary build directory, and switch to it
cd ~/opencv_build/opencvmkdir build && cd build
Set up the OpenCV build with CMake
cmake -D CMAKE_BUILD_TYPE=RELEASE \-D CMAKE_INSTALL_PREFIX=/usr/local \-D INSTALL_C_EXAMPLES=ON \-D INSTALL_PYTHON_EXAMPLES=ON \-D OPENCV_GENERATE_PKGCONFIG=ON \-D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \-D BUILD_EXAMPLES=ON ..
Start the compilation process
make -j8
Install OpenCV
make install
pkg-config --modversion opencv4
Tuesday, April 19, 2022
How to Install and configure Conky Widgets on Ubuntu
Prerequisites
- Ubuntu Linux installed desktop PC
- Install "conky" and "conky-all" on your PC
- Download URL: URL
- Unzip it under user home directory
- Open Tweaks -> Startup Applications
- Add "conky-startup.sh" script to start at startup

































