Server Configuration Deep Dive: Optimizing Performance and Security

Posted by on | 1542 views | 42 replies
AD

Hello everyone,

This thread is dedicated to discussing advanced server configuration techniques. We'll cover topics like optimizing Nginx/Apache, fine-tuning MySQL/PostgreSQL, enhancing SSH security, and implementing robust caching strategies (Redis, Memcached). Let's aim to share practical tips and real-world examples to help us all build more performant and secure web infrastructure.

Key areas to consider:

  • Web Server: Connection limits, keep-alive settings, GZIP compression.
  • Database: Query optimization, indexing, buffer pool tuning.
  • Security: Firewall rules, fail2ban, SSH key authentication, disabling root login.
  • Caching: Browser caching, CDN integration, application-level caching.

Looking forward to your contributions!

Reply Like (15) Share
JD

Great topic! For Nginx, I've found that setting worker_processes auto; and tuning worker_connections based on your server's RAM and CPU cores can make a significant difference. Also, using open_file_cache effectively reduces lookup times for static assets.

Here's a snippet I use:


http {
    # ... other settings ...
    worker_processes auto;
    worker_connections 4096;
    multi_accept on;

    open_file_cache max=2000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;
    # ... other settings ...
}
                        

Any thoughts on the optimal worker_connections for a typical VPS?

Reply Like (8) Share
SA

Regarding database security, I highly recommend disabling direct root login via SSH and enforcing SSH key authentication. This significantly reduces the attack surface.

In your sshd_config file:


PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
                        

Remember to test your key login before disabling password auth entirely!

Reply Like (12) Share

Post a Reply