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/;
    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/ levels=1:2 max_size=10g inactive=60m use_temp_path=off;
    server {
        listen 80;
        root /var/www/;
        index index.php index.html index.htm;
        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_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;
              include /etc/nginx/proxy_params;
        listen 443 ssl http2; 
        ssl_certificate /etc/nginx/ssl/;
        ssl_certificate_key /etc/nginx/ssl/;

Can someone please advise what can be wrong?

Regards, Jacques

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


I have done so but there is no error at all.

But having a very closed look, I notice that the 500 error are through when Nginx send 103 status code to apache (honestly not sure why) - - [08/Feb/2020:15:54:47 +0000] “GET /index.php HTTP/1.1” 103 32998 “-” “curl/7.64.1”

Can someone have glue? Is there a way to disable 103 status code?

Hi @guiffo,

Looking at your Configuration files, I can’t seem to find a part in the Apache one where you’ve configured error_logs. Can you add this and see what the error is when the 500 Error is generated?

Additionally, is it a 500 Internal Server Error or is it 500 Http error? The difference is the first one is server related and the second one application related.

In such case, what I’ll recommend is trying to find a way to recreate the issue and act upon it then.

Regards, KDSys