How 0x1ceking/mywebstorewithmodsecurity works
Main Components
• Frontend Web Client: This is represented by the static web pages and views (HTML, CSS, JS) housed under the src/main/webapp directory. There are separate views for admin and user interfaces.
• Java Spring Boot Backend: The primary application logic is implemented here. Look at packages like com/web/controller, com/web/service, com/web/repository, and the main application entry point (WebstoreApplication.java). This component contains the business logic for user authentication, product management, payment processing (with MoMo integration), and more.
• MySQL Database: Acts as the persistent storage for entities such as User, Product, Invoice, and others. The pom.xml indicates the use of frameworks that handle persistence (JPA/Hibernate).
• Nginx Proxy with ModSecurity: Located in the “NginxProxy_ModSecurityWaf” directory. This container is configured to use ModSecurity firewall rules (OWASP CRS, modsecurity.conf and related files) and serves as the first line of defense against malicious traffic.
• Docker & Docker Compose Environment: The Dockerfile at the project root and the docker-compose.yml file show the system is containerized, allowing each major component (Spring Boot app, MySQL, PhpMyAdmin, and Nginx ModSecurity proxy) to run in separate containers.
Interactions and Relationships
• The Frontend Web Client sends HTTP requests (both for page views and API calls) to the Java Spring Boot application.
• The Spring Boot backend handles these requests through various controllers. It then processes business logic, accesses the MySQL database (via JPA repositories), and communicates results back to the client.
• For administrative tasks or user activities (e.g., login, checkout, etc.), backend services (especially security and payment services) are invoked.
• Any external payment interactions (as indicated by the MoMo services and related models/processors) connect the backend with external payment gateways.
• The Nginx container sits at the network edge, acting as a reverse proxy. It checks incoming traffic with ModSecurity rules before passing requests to the backend application. This ensures that malicious requests are filtered out.
• Docker Compose orchestrates the overall deployment, defining network connections and service dependencies (so the Nginx container routes to the Spring Boot service, which in turn connects to the MySQL container).
Important Architectural Patterns and Design Principles
• Modular Separation: The project clearly separates concerns into frontend (presentation), backend (business logic), database (data persistence), and security components.
• Containerization: Emphasis on Docker and Docker Compose enables scalability, simplified deployment, and isolation between components.
• Security Integration: The addition of ModSecurity via an Nginx proxy demonstrates an external layered approach for web security.
• MVC Pattern: The Spring Boot architecture uses controllers, models, and views reflecting an MVC style in both the admin and user modules.
Relevant Technologies, Frameworks, and Libraries
• Java Spring Boot for server-side logic.
• Docker and Docker Compose for containerization.
• MySQL as the relational database, with PhpMyAdmin for administration.
• Nginx with ModSecurity for web application firewall capabilities.
• Maven for dependency management and build processes.
• Additional libraries for mail sending, cloud configurations, and payment processing (e.g., integration with MoMo).