Question
Random 500 error with Nginx reverse proxy Apache without error log
Hello all
I am getting some weird problem on my Nginx reverse proxy apache settings.
There is a random 500 error status code but nothing in the error log files (I can say it a about 20% of the traffic) as the site receives some thousand visits daily.
This is my Nginx config file
user www-data;
worker_processes 4;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 4096; ## max clients = worker_processes * worker_connections
multi_accept on;
use epoll;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
client_body_timeout 12;
client_header_timeout 12;
send_timeout 10;
types_hash_max_size 2048;
server_tokens off;
proxy_buffering on;
proxy_buffer_size 16k;
proxy_buffers 64 4k;
proxy_busy_buffers_size 24k;
include /etc/nginx/mime.types;
default_type application/octet-stream;
## more tuning
client_max_body_size 30M;
client_body_buffer_size 12K;
server_names_hash_max_size 1024;
server_names_hash_bucket_size 112;
client_header_buffer_size 2k;
large_client_header_buffers 6 8k;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
#access_log off;
log_not_found off;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_vary on;
gzip_min_length 1000;
gzip_comp_level 9;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_disable "MSIE [1-6]\.";
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
And this is an example of a site config file.
## Static cache settings #
proxy_cache_path /tmp/site.com levels=1:2 keys_zone=temgo_cache_zone-site.com:15m max_size=10g inactive=60m use_temp_path=off;
server {
listen 80;
root /var/www/site.com;
index index.php index.html index.htm;
server_name site.com www.site.com;
location ~ ^(.*)\.(inc|inc\.php|sql|ht|htaccess)$ {
deny all;
}
location / {
try_files $uri $uri/ =404;
}
## Include full Mod rewrite rules
include /etc/nginx/ssl/site_global_rewrite.conf;
set $no_cache 0;
if ($request_uri ~* "(/login.php|/register.php|/user.php)"){
set $no_cache 1;
}
location ~ \.php$ {
proxy_cache temgo_cache_zone-site.com;
proxy_cache_key "$scheme$request_method$host$request_uri$is_Mobile_Browser$cookie_DeviceType$cookie__gallery"; ## Based on Mobile Device
proxy_cache_bypass $no_cache;
proxy_cache_revalidate on;
proxy_cache_min_uses 1;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_cache_background_update on;
proxy_cache_lock on;
add_header Strict-Transport-Security "max-age=47474747; includeSubDomains; preload";
add_header Content-Security-Policy upgrade-insecure-requests;
add_header X-Frame-Options sameorigin always;
add_header X-Cache-Status $upstream_cache_status;
proxy_pass http://127.0.0.1:8080;
include /etc/nginx/proxy_params;
}
listen 443 ssl http2;
ssl_certificate /etc/nginx/ssl/site.com.crt;
ssl_certificate_key /etc/nginx/ssl/site.com.key;
}
Can someone please advise what can be wrong?
Regards,
Jacques
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×