Category Archives: nginx

nginx – failed (13: Permission denied)

In a fresh CENTOS, while installing & testing nginx i’v faced the following error..

2019/10/10 17:54:11 [crit] 18960#0: *1 stat() "/home/www/html/index.php" failed (13: Permission denied), client:, server:, request: "GET /index.php HTTP/1.1", host: ""

This is how I’v solved.

chcon -R -t httpd_sys_content_t /home/www/html/

More readings

/.well-known/acme-challenge/ – 404


1 renew failure(s), 0 parse failure(s)

 - The following errors were reported by the server:

 Type: unauthorized
 Detail: Invalid response from
 "<!DOCTYPE html>
 <html lang="en">
 <title>404 Page Not Found</title>
 <style type="text/css">

::selection{ background-color"

To fix these errors, please make sure that your domain name was
 entered correctly and the DNS A record(s) for that domain
 contain(s) the right IP address.

Try to add the following, inside server{}, on user nginx domain configuration..

location /.well-known/acme-challenge/ {
    try_files $uri /dev/null =404;

And reboot nginx… ūüôā

letsencrypt renew – 404 – Detail: Invalid response


letsencrypt renew output

Type: unauthorized
Detail: Invalid response from

nginx error log

66.133.XXX.XXX - - [11/Feb/2017:09:33:20 +0100] "GET /.well-known/acme-challenge/WLpdvugG3YzC53RTrZMJcYWsRqcj64vWLw43HNBkMN6 HTTP/1.1" 404 247 "" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +"

“Somehow” my domain root has changed.
I had to take a look at¬†/etc/letsencrypt/renewal/ and fix some paths… ūüôā


Warning: Unknown: open(/var/lib/php/session/ O_RDWR) failed: Permission denied (13)

I was getting the following error on a *fresh* CentOS…

Warning: Unknown: open(/var/lib/php/session/sess_isu2r2bqudeosqvpoo8a67oj02, O_RDWR) failed: Permission denied (13) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0

This will do the work…

chown -R nginx:nobody /var/lib/php/session && chmod -R 770 /var/lib/php/session

CRITICAL | | (Return code of 255 is out of bounds)


My nagios was returning a CRITICAL error on one of my servers…

CRITICAL | | (Return code of 255 is out of bounds)

and httpd server wasn’t responding….

I think that problem was on IPTABLES / FAIL2BAN ban list. I had 702 banned IPs…
After I clean them up, everything went okay!


I was playing hard with them… my¬†bantime was¬†3600000 (41d) and my findtime was¬†60000 (16h)…


SSL tutorials

Just bought a SSL certificate for one of my clients….
Here are some useful tutorial links.—

CSR Generation: Using OpenSSL (Apache w/mod_ssl, NGINX, OS X)

Nginx CSR Generation using OpenSSL

Certificate Installation: Apache & mod_ssl

Certificate Installation : NGINX–nginx

nginx&cloudflare – allow ip to directory


One of my blogs is getting lots of login attempts from HACKERS :>

Only allow specific IP to access a specific directory

Inside the configuration of the domain (ex. /etc/nginx/sites-enabled/, lets add the following entries Рthis will allow IP 84.91.XXX.XXX to wp-admin folder and block all the others

 location /full_movies/ {
      allow 84.91.XXX.XXX;
      deny all;

This should to the trick! but if we¬†are using cloudflare the¬†domain we need to add some lines at our¬†nginx.conf¬†(/etc/nginx/nginx.conf) so nginx reads the correct IP from the visitor…
Inside http { lets add the following

real_ip_header CF-Connecting-IP;


To protect your wordpress login & wp-admin…

  location ~ '(/wp-login.php|/wp-admin)' {
            deny all;

This might affect your theme/plugins.
It protects /wp-admin/wp-ajax.php….

500 Internal Server Error while uploading files

I was having a 500 Internal Server Error…
nginx logs were showing me the following

2016/03/17 12:09:32 [crit] 31488#0: *11192 open() "/var/lib/nginx/tmp/client_body/0000000005" failed (13: Permission denied), client: 84.91.XXX.XXX, server:, request: "POST /trades_edit/edit_trade HTTP/1.1", host: "", referrer: ""


chown -R www-data:www-data /var/lib/nginx