Initial commit - WASL Digital Wallet
This commit is contained in:
95
Backend/docker/nginx/default.conf
Normal file
95
Backend/docker/nginx/default.conf
Normal file
@@ -0,0 +1,95 @@
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# WASL — Nginx server block (API)
|
||||
# Proxies to Laravel Octane (Swoole) on app:8000
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
|
||||
root /var/www/html/public;
|
||||
index index.php;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
# ── Health check endpoint ──
|
||||
location = /up {
|
||||
access_log off;
|
||||
proxy_pass http://wasl_octane;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
}
|
||||
|
||||
# ── Block sensitive files ──
|
||||
location ~ /\.(?!well-known).* {
|
||||
deny all;
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
location ~* ^/(?:storage|app|bootstrap|config|database|resources|routes|tests|vendor|docker)(/.*)?$ {
|
||||
deny all;
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
# ── Static assets (cached) ──
|
||||
location ~* \.(?:css|js|jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# ── API rate limits (login & transfers throttled harder) ──
|
||||
location ~ ^/api/(auth|otp|login) {
|
||||
limit_req zone=login burst=5 nodelay;
|
||||
limit_req_status 429;
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ ^/api/(transfers|wallets/.*/transfer) {
|
||||
limit_req zone=transfer burst=3 nodelay;
|
||||
limit_req_status 429;
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
# ── General API + app ──
|
||||
location / {
|
||||
limit_req zone=api burst=30 nodelay;
|
||||
limit_req_status 429;
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
# ── PHP via Octane (Swoole) ──
|
||||
location ~ \.php$ {
|
||||
proxy_pass http://wasl_octane;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
proxy_read_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_connect_timeout 5s;
|
||||
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
}
|
||||
|
||||
# ── Custom error pages ──
|
||||
error_page 404 /index.php;
|
||||
error_page 429 = @ratelimit;
|
||||
location @ratelimit {
|
||||
default_type application/json;
|
||||
return 429 '{"success":false,"message":"Too many requests. Please slow down.","code":"RATE_LIMITED"}';
|
||||
}
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
}
|
||||
74
Backend/docker/nginx/nginx.conf
Normal file
74
Backend/docker/nginx/nginx.conf
Normal file
@@ -0,0 +1,74 @@
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# WASL — Nginx main config
|
||||
# Hardened reverse proxy in front of Laravel Octane (Swoole)
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
worker_rlimit_nofile 65535;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 4096;
|
||||
multi_accept on;
|
||||
use epoll;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# ── Logging ──
|
||||
log_format main '$remote_addr - $remote_user [$time_local] '
|
||||
'"$request" $status $body_bytes_sent '
|
||||
'"$http_referer" "$http_user_agent" '
|
||||
'rt=$request_time urt=$upstream_response_time';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
# ── Performance ──
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
keepalive_requests 1000;
|
||||
types_hash_max_size 2048;
|
||||
server_tokens off;
|
||||
|
||||
# ── Client body limits (KYC docs up to ~10MB) ──
|
||||
client_max_body_size 15m;
|
||||
client_body_buffer_size 128k;
|
||||
client_body_timeout 30s;
|
||||
client_header_timeout 30s;
|
||||
|
||||
# ── Gzip ──
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
# ── Security headers ──
|
||||
server_tokens off;
|
||||
add_header X-Frame-Options "DENY" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
||||
|
||||
# ── Rate limiting zones ──
|
||||
limit_req_zone $binary_remote_addr zone=api:10m rate=30r/s;
|
||||
limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m;
|
||||
limit_req_zone $binary_remote_addr zone=transfer:10m rate=10r/m;
|
||||
|
||||
# ── Upstream to Octane (Swoole) ──
|
||||
upstream wasl_octane {
|
||||
server app:8000 max_fails=3 fail_timeout=5s;
|
||||
keepalive 64;
|
||||
}
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
31
Backend/docker/php/dev.ini
Normal file
31
Backend/docker/php/dev.ini
Normal file
@@ -0,0 +1,31 @@
|
||||
; ─────────────────────────────────────────────────────────────
|
||||
; WASL — Development PHP settings
|
||||
; ─────────────────────────────────────────────────────────────
|
||||
|
||||
display_errors = On
|
||||
display_startup_errors = On
|
||||
log_errors = On
|
||||
error_reporting = E_ALL
|
||||
|
||||
memory_limit = 512M
|
||||
max_execution_time = 120
|
||||
upload_max_filesize = 50M
|
||||
post_max_size = 50M
|
||||
|
||||
; OPcache (with validation for dev hot-reload)
|
||||
opcache.enable = 1
|
||||
opcache.enable_cli = 1
|
||||
opcache.memory_consumption = 128
|
||||
opcache.max_accelerated_files = 10000
|
||||
opcache.validate_timestamps = 1
|
||||
opcache.revalidate_freq = 0
|
||||
|
||||
date.timezone = Asia/Damascus
|
||||
|
||||
; Xdebug
|
||||
[xdebug]
|
||||
xdebug.mode = debug,develop,coverage
|
||||
xdebug.start_with_request = trigger
|
||||
xdebug.client_host = host.docker.internal
|
||||
xdebug.client_port = 9003
|
||||
xdebug.log = /dev/stderr
|
||||
55
Backend/docker/php/production.ini
Normal file
55
Backend/docker/php/production.ini
Normal file
@@ -0,0 +1,55 @@
|
||||
; ─────────────────────────────────────────────────────────────
|
||||
; WASL — Production PHP settings
|
||||
; Conservative limits, security-focused, opcache optimized
|
||||
; ─────────────────────────────────────────────────────────────
|
||||
|
||||
; Errors: NEVER display in production (financial system)
|
||||
display_errors = Off
|
||||
display_startup_errors = Off
|
||||
log_errors = On
|
||||
error_log = /dev/stderr
|
||||
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
|
||||
|
||||
; Performance
|
||||
memory_limit = 512M
|
||||
max_execution_time = 30
|
||||
max_input_time = 60
|
||||
max_input_vars = 3000
|
||||
post_max_size = 20M
|
||||
upload_max_filesize = 10M
|
||||
|
||||
; OPcache — critical for production performance
|
||||
opcache.enable = 1
|
||||
opcache.enable_cli = 1
|
||||
opcache.memory_consumption = 256
|
||||
opcache.max_accelerated_files = 20000
|
||||
opcache.validate_timestamps = 0
|
||||
opcache.revalidate_freq = 2
|
||||
opcache.interned_strings_buffer = 32
|
||||
opcache.fast_shutdown = 1
|
||||
opcache.jit = tracing
|
||||
opcache.jit_buffer_size = 64M
|
||||
|
||||
; Realpath cache (improves file inclusion performance)
|
||||
realpath_cache_size = 4096K
|
||||
realpath_cache_ttl = 600
|
||||
|
||||
; Session hardening
|
||||
session.cookie_httponly = 1
|
||||
session.cookie_secure = 1
|
||||
session.cookie_samesite = "Strict"
|
||||
session.use_strict_mode = 1
|
||||
session.gc_maxlifetime = 1200
|
||||
|
||||
; Exposure
|
||||
expose_php = Off
|
||||
|
||||
; Date
|
||||
date.timezone = Asia/Damascus
|
||||
|
||||
; Swoole runtime config
|
||||
swoole.enable_library = On
|
||||
swoole.enable_preemptive_scheduler = On
|
||||
|
||||
; Disable functions that could be abused
|
||||
disable_functions = exec,passthru,shell_exec,system,proc_open,popen,curl_multi_exec,parse_ini_file,show_source
|
||||
19
Backend/docker/postgres/init.sql
Normal file
19
Backend/docker/postgres/init.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- ─────────────────────────────────────────────────────────────
|
||||
-- WASL — PostgreSQL initialization
|
||||
-- Runs once when the postgres container initializes the data dir.
|
||||
-- ─────────────────────────────────────────────────────────────
|
||||
|
||||
-- Ensure required extensions are enabled for the WASL database
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; -- gen_random_uuid() / uuid-ossp
|
||||
CREATE EXTENSION IF NOT EXISTS "pgcrypto"; -- encryption helpers (pgp_sym_encrypt)
|
||||
CREATE EXTENSION IF NOT EXISTS "citext"; -- case-insensitive text (emails)
|
||||
CREATE EXTENSION IF NOT EXISTS "pg_trgm"; -- trigram fuzzy search (phone lookup)
|
||||
CREATE EXTENSION IF NOT EXISTS "btree_gin"; -- composite GIN indexes
|
||||
|
||||
-- Create the test database if running in development
|
||||
SELECT 'CREATE DATABASE wasl_testing OWNER wasl'
|
||||
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'wasl_testing')\gexec
|
||||
|
||||
-- Set default search path
|
||||
ALTER DATABASE wasl SET search_path TO public;
|
||||
ALTER DATABASE wasl SET timezone TO 'Asia/Damascus';
|
||||
65
Backend/docker/supervisor/supervisord.conf
Normal file
65
Backend/docker/supervisor/supervisord.conf
Normal file
@@ -0,0 +1,65 @@
|
||||
; ─────────────────────────────────────────────────────────────
|
||||
; WASL — Supervisor config
|
||||
; Manages long-running processes: Octane server + queue workers
|
||||
; ─────────────────────────────────────────────────────────────
|
||||
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
logfile=/dev/stderr
|
||||
logfile_maxbytes=0
|
||||
pidfile=/var/run/supervisord.pid
|
||||
|
||||
[unix_http_server]
|
||||
file=/var/run/supervisor.sock
|
||||
chmod=0700
|
||||
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
|
||||
[supervisorctl]
|
||||
serverurl=unix:///var/run/supervisor.sock
|
||||
|
||||
; ── Laravel Octane (Swoole) — main application server ──
|
||||
[program:octane]
|
||||
command=php artisan octane:start --server=swoole --host=0.0.0.0 --port=8000 --max-requests=10000
|
||||
directory=/var/www/html
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startretries=3
|
||||
user=www-data
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stopwaitsecs=15
|
||||
stopsignal=TERM
|
||||
killasgroup=true
|
||||
stopasgroup=true
|
||||
|
||||
; ── Queue worker (processes async jobs: notifications, reconciliation) ──
|
||||
[program:queue]
|
||||
command=php artisan queue:work redis --tries=3 --backoff=10 --max-time=3600 --queue=default,transfers,notifications
|
||||
directory=/var/www/html
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startretries=3
|
||||
user=www-data
|
||||
numprocs=2
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stopwaitsecs=30
|
||||
stopsignal=TERM
|
||||
killasgroup=true
|
||||
stopasgroup=true
|
||||
|
||||
; ── Scheduled task runner (cron-style Laravel scheduler) ──
|
||||
[program:scheduler]
|
||||
command=php artisan schedule:work
|
||||
directory=/var/www/html
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=www-data
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
Reference in New Issue
Block a user