The Web Traffic Anomaly Detector is a Ruby on Rails application designed to monitor web traffic logs and detect anomalies such as high traffic from a single IP address or unusual request patterns. The project aims to help identify potential issues like bot attacks, unauthorized access, or other irregular activities in web server traffic.
Clone the Repository:
git clone https://github.com/your-username/web-traffic-anomaly-detector.git
cd web-traffic-anomaly-detector
Install Dependencies:
bundle install
Set Up Database:
Create and migrate the database:
rails db:create
rails db:migrate
Configure Web Server:
Set up Apache or Nginx on your local machine to generate logs. Ensure logs are accessible by your Rails application for ingestion.
Start the Rails Server:
rails server
Setup Redis, Sidekiq
sudo apt update
sudo apt install redis-server
sudo systemctl start redis-server
sudo systemctl status redis-server
gem 'sidekiq'
bundle exec sidekiq
config/initializers/sidekiq.rb
config/application.rb
sudo a2ensite web_server_test.conf
sudo systemctl reload apache2
Create a sample HTML file for testing in /path/to/your/workspace/web_server_test/html/index.html
Create Log Parsing Script Create a log parsing script in lib/log_parsers/parse_logs.rb:
rails generate job AnomalyDetection
bundle exec sidekiq
rails generate mailer AnomalyMailer
config/environments/development.rb
app/views/anomaly_mailer/anomaly_alert.html.erb
app/services/anomaly_detector.rb
anomaly = Anomaly.first
AnomalyMailer.anomaly_alert(anomaly).deliver_now