Understanding Nginx

EGPHP uses Nginx (pronounced "engine-x") as its web server. Nginx is known for its high performance, stability, and low resource usage. Unlike Apache, Nginx doesn't use .htaccess files.

No .htaccess: Nginx doesn't support .htaccess files. Similar functionality is achieved through Nginx configuration files.

Accessing Nginx Settings

  1. Log in to EGPNL
  2. Go to Domains
  3. Click on your domain
  4. Select Nginx Config or Advanced Settings

Common Nginx Configurations

Redirect HTTP to HTTPS

Force all traffic to use HTTPS:

if ($scheme != "https") {
    return 301 https://$host$request_uri;
}

Redirect www to non-www

if ($host ~* ^www\.(.*)) {
    return 301 https://$1$request_uri;
}

Redirect non-www to www

if ($host !~* ^www\.) {
    return 301 https://www.$host$request_uri;
}

WordPress Pretty Permalinks

Required for WordPress SEO-friendly URLs:

location / {
    try_files $uri $uri/ /index.php?$args;
}
WordPress Users: EGPNL automatically configures WordPress permalinks when you add a WordPress site. No manual configuration needed!

Security Headers

Add security headers to protect your site:

add_header X-Frame-Options "SAMEORIGIN" 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;

Caching Configuration

Enable browser caching for static files:

location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2|woff|ttf)$ {
    expires 30d;
    add_header Cache-Control "public, immutable";
}

Gzip Compression

Enable gzip compression for faster page loads (usually enabled by default):

gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
gzip_min_length 1000;

Custom Error Pages

Set custom 404 and 500 error pages:

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;

Blocking Access

Block Specific IPs

deny 123.45.67.89;
deny 98.76.54.0/24;

Block Specific Files

location ~ /\.(htaccess|htpasswd|git|svn) {
    deny all;
}

Password Protect a Directory

location /admin {
    auth_basic "Restricted";
    auth_basic_user_file /path/to/.htpasswd;
}

URL Rewrites

Rewrite URLs without redirecting:

# Rewrite old URL to new URL internally
rewrite ^/old-page$ /new-page last;

# Redirect old URL to new URL (301)
rewrite ^/old-url$ /new-url permanent;

PHP Configuration

Adjust PHP settings for your domain:

location ~ \.php$ {
    fastcgi_param PHP_VALUE "
        upload_max_filesize=64M
        post_max_size=64M
        max_execution_time=300
    ";
}
Be Careful: Incorrect Nginx configuration can make your website inaccessible. Always backup your current configuration before making changes.

Testing Configuration

After making changes:

  1. EGPNL will validate your configuration automatically
  2. If there are errors, you'll see a warning message
  3. Fix any errors before saving
  4. Nginx will reload automatically after successful save