Back to Generator
mail.ru
Node.js
Created January 20, 2026 at 21:11
mail.ru
Configuration saved • Node.js
# mail.ru - Generated by NginxForge
# Preset: Node.js
# Generated: 2026-01-20 21:11:50 UTC
upstream mail_ru_backend {
server 127.0.0.1:3000;
keepalive 64;
}
# HTTP -> HTTPS redirect
server {
listen 80;
listen [::]:80;
server_name mail.ru www.mail.ru;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
allow all;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/letsencrypt/live/mail.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mail.ru/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
server_name mail.ru www.mail.ru;
root /var/www/mail.ru;
index index.html index.htm;
server_tokens off;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Content-Security-Policy "upgrade-insecure-requests" always;
# Allowed methods
if ($request_method !~ ^(GET|POST|HEAD)$) {
return 405;
}
# Gzip compression
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_min_length 1000;
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy
text/xml;
client_max_body_size 64m;
# Node.js application configuration
location / {
proxy_pass http://mail_ru_backend;
proxy_http_version 1.1;
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_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# Static assets
location ~ ^/(assets|dist|public)/ {
root /var/www/mail.ru;
expires 30d;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# Static file caching
location ~* \.(jpg|jpeg|png|gif|ico|webp|svg|woff|woff2|ttf|eot|otf)$ {
expires 30d;
add_header Cache-Control "public, immutable";
access_log off;
log_not_found off;
}
location ~* \.(css|js)$ {
expires 30d;
add_header Cache-Control "public, immutable";
access_log off;
}
location ~* \.(pdf|doc|docx|xls|xlsx|zip|rar|gz|tar)$ {
expires 7d;
add_header Cache-Control "public";
}
# Deny access to hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
access_log /var/log/nginx/mail.ru.access.log;
error_log /var/log/nginx/mail.ru.error.log;
}
#!/bin/bash
# ============================================================
# mail.ru - Setup Script
# Generated by NginxForge
# Preset: Node.js
# Generated: 2026-01-20 21:11:50 UTC
# ============================================================
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
# Check root
[[ $EUID -ne 0 ]] && log_error "This script must be run as root"
DOMAIN="mail.ru"
ROOT_PATH="/var/www/mail.ru"
NGINX_CONF="/etc/nginx/sites-available/${DOMAIN}"
NGINX_ENABLED="/etc/nginx/sites-enabled/${DOMAIN}"
log_info "Starting setup for ${DOMAIN}..."
# ============================================================
# 1. Install dependencies
# ============================================================
log_info "Installing dependencies..."
apt-get update -qq
PACKAGES="nginx"
PACKAGES="$PACKAGES certbot python3-certbot-nginx"
apt-get install -y -qq $PACKAGES
log_success "Dependencies installed"
# ============================================================
# 2. Create directories
# ============================================================
log_info "Creating directories..."
mkdir -p "${ROOT_PATH}"
mkdir -p /var/www/certbot
mkdir -p /var/log/nginx
chown -R www-data:www-data "${ROOT_PATH}"
chmod -R 755 "${ROOT_PATH}"
log_success "Directories created"
# ============================================================
# 3. Deploy nginx configuration
# ============================================================
log_info "Deploying nginx configuration..."
cat > "${NGINX_CONF}" << 'NGINX_CONFIG'
# mail.ru - Generated by NginxForge
# Preset: Node.js
# Generated: 2026-01-20 21:11:50 UTC
upstream mail_ru_backend {
server 127.0.0.1:3000;
keepalive 64;
}
# HTTP -> HTTPS redirect
server {
listen 80;
listen [::]:80;
server_name mail.ru www.mail.ru;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
allow all;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/letsencrypt/live/mail.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mail.ru/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
server_name mail.ru www.mail.ru;
root /var/www/mail.ru;
index index.html index.htm;
server_tokens off;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Content-Security-Policy "upgrade-insecure-requests" always;
# Allowed methods
if ($request_method !~ ^(GET|POST|HEAD)$) {
return 405;
}
# Gzip compression
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_min_length 1000;
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy
text/xml;
client_max_body_size 64m;
# Node.js application configuration
location / {
proxy_pass http://mail_ru_backend;
proxy_http_version 1.1;
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_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# Static assets
location ~ ^/(assets|dist|public)/ {
root /var/www/mail.ru;
expires 30d;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# Static file caching
location ~* \.(jpg|jpeg|png|gif|ico|webp|svg|woff|woff2|ttf|eot|otf)$ {
expires 30d;
add_header Cache-Control "public, immutable";
access_log off;
log_not_found off;
}
location ~* \.(css|js)$ {
expires 30d;
add_header Cache-Control "public, immutable";
access_log off;
}
location ~* \.(pdf|doc|docx|xls|xlsx|zip|rar|gz|tar)$ {
expires 7d;
add_header Cache-Control "public";
}
# Deny access to hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
access_log /var/log/nginx/mail.ru.access.log;
error_log /var/log/nginx/mail.ru.error.log;
}
NGINX_CONFIG
# Enable site
ln -sf "${NGINX_CONF}" "${NGINX_ENABLED}"
# Test configuration
nginx -t || log_error "Nginx configuration test failed"
log_success "Nginx configuration deployed"
# ============================================================
# 4. SSL Certificate
# ============================================================
log_info "Obtaining SSL certificate from Let's Encrypt..."
# First, reload nginx with HTTP-only config for ACME challenge
systemctl reload nginx
certbot certonly \
--nginx \
-d mail.ru \
-d www.mail.ru \
--register-unsafely-without-email \
--agree-tos \
--non-interactive \
--redirect
# Setup auto-renewal
systemctl enable certbot.timer
systemctl start certbot.timer
log_success "SSL certificate obtained and auto-renewal configured"
# ============================================================
# 5. Configure firewall
# ============================================================
log_info "Configuring firewall..."
if command -v ufw &> /dev/null; then
ufw allow 'Nginx Full' || true
log_success "UFW configured"
else
log_warn "UFW not installed, skipping firewall configuration"
fi
# ============================================================
# 6. Start/Reload services
# ============================================================
log_info "Starting services..."
systemctl enable nginx
systemctl reload nginx
log_success "Services started"
# ============================================================
# 7. Create test page
# ============================================================
# ============================================================
# Summary
# ============================================================
echo ""
echo -e "${GREEN}============================================================${NC}"
echo -e "${GREEN} Setup Complete!${NC}"
echo -e "${GREEN}============================================================${NC}"
echo ""
echo -e "Domain: ${BLUE}mail.ru${NC}"
echo -e "URL: ${BLUE}https://mail.ru${NC}"
echo -e "Root: ${BLUE}${ROOT_PATH}${NC}"
echo -e "Nginx conf: ${BLUE}${NGINX_CONF}${NC}"
echo -e "Access log: ${BLUE}/var/log/nginx/mail.ru.access.log${NC}"
echo -e "Error log: ${BLUE}/var/log/nginx/mail.ru.error.log${NC}"
echo ""
echo -e "${YELLOW}[!] Remember to start your application on port 3000${NC}"
echo ""
#!/bin/bash
# ============================================================
# mail.ru - Removal Script
# Generated by NginxForge
# ============================================================
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
[[ $EUID -ne 0 ]] && log_error "This script must be run as root"
DOMAIN="mail.ru"
ROOT_PATH="/var/www/mail.ru"
NGINX_CONF="/etc/nginx/sites-available/${DOMAIN}"
NGINX_ENABLED="/etc/nginx/sites-enabled/${DOMAIN}"
echo -e "${RED}============================================================${NC}"
echo -e "${RED} WARNING: This will remove ${DOMAIN}${NC}"
echo -e "${RED}============================================================${NC}"
echo ""
echo "This script will:"
echo " - Remove nginx configuration"
echo " - Revoke SSL certificate (if any)"
echo " - Optionally delete site files"
echo ""
read -p "Are you sure? (y/N): " -n 1 -r
echo ""
[[ ! $REPLY =~ ^[Yy]$ ]] && exit 0
# ============================================================
# 1. Remove nginx configuration
# ============================================================
log_info "Removing nginx configuration..."
rm -f "${NGINX_ENABLED}"
rm -f "${NGINX_CONF}"
nginx -t && systemctl reload nginx
log_success "Nginx configuration removed"
# ============================================================
# 2. Remove SSL certificate
# ============================================================
log_info "Revoking SSL certificate..."
if [[ -d "/etc/letsencrypt/live/${DOMAIN}" ]]; then
certbot delete --cert-name "${DOMAIN}" --non-interactive || true
log_success "SSL certificate revoked"
else
log_warn "No certificate found"
fi
# ============================================================
# 3. Remove site files (optional)
# ============================================================
echo ""
read -p "Delete site files at ${ROOT_PATH}? (y/N): " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [[ -d "${ROOT_PATH}" ]]; then
rm -rf "${ROOT_PATH}"
log_success "Site files deleted"
else
log_warn "Directory not found"
fi
else
log_info "Site files preserved at ${ROOT_PATH}"
fi
# ============================================================
# 4. Remove log files (optional)
# ============================================================
read -p "Delete log files? (y/N): " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -f "/var/log/nginx/${DOMAIN}.access.log"
rm -f "/var/log/nginx/${DOMAIN}.error.log"
log_success "Log files deleted"
fi
# ============================================================
# Summary
# ============================================================
echo ""
echo -e "${GREEN}============================================================${NC}"
echo -e "${GREEN} ${DOMAIN} has been removed${NC}"
echo -e "${GREEN}============================================================${NC}"
echo ""
Quick Deploy (one-liner)
curl -sSL http://localhost:8081/raw/V5ZeIMZQMLgmdETa/setup | sudo bash