server {
    include listen;
    include listen_ssl;
    include includes/letsencrypt;

    server_name example.com dev.example.com ;

    disable_symlinks if_not_owner from=$root_path;
    set $root_path /home/example_com/data/www/example_com;
    index index.html index.php index.htm;

    location / {
        proxy_pass http://127.0.0.1:81;
        proxy_redirect http://127.0.0.1:81/ /;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location @apache {
        proxy_pass http://127.0.0.1:81;
        proxy_redirect http://127.0.0.1:81/ /;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location ~* ^.+\.(jpg|jpeg|gif|png|rar|txt|tar|wav|bz2|exe|pdf|doc|xls|ppt|bmp|rtf|js|ico|css|zip|tgz|gz)$ {
        root $root_path;
        expires 30d;
        error_page 404 = @apache;
    }

    location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin|phpmyadmin)/ {
        error_page 404 = @apache;
        return 404;
    }

    location ~ /\.ht {
        return 404;
    }

}
