Common Problems
- 403 Forbidden errors (permission issues).
- 502 Bad Gateway (proxy errors).
- Rewrite rules not working.
How to Fix:
1. Apache: Fix 403 Forbidden
Check directory permissions and .htaccess
:
AllowOverride All
Require all granted
2. Nginx: Resolve 502 Bad Gateway
Increase proxy timeouts in /etc/nginx/conf.d/default.conf
:
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
3. Test Configuration Syntax
sudo apachectl configtest # Apache
sudo nginx -t # Nginx
4. Redirect HTTP to HTTPS (Nginx)
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
Prevention Tips
- Use Apache Docs or Nginx Docs for reference.
- Backup config files before making changes.
- Use
sudo
carefully to avoid permission mishaps.
Note: Restart servers after config changes:
sudo systemctl restart apache2 # Apache
sudo systemctl restart nginx # Nginx