R
R
Rinat Haisman2017-12-02 19:05:00
CMS
Rinat Haisman, 2017-12-02 19:05:00

Why is WordPress giving a 403 forbidden nginx error on my site?

Greetings. The problem is that the site almost always gives 403 errors on the main page, and 404 on the inner pages. And in other browsers, usually the whole site starts up normally, without problems. But sometimes Mozilla writes the same errors.
I did the following:
1. Set the necessary permissions for folders/files
2. Disable/enable all plugins
3. Disable/enable caching
4. Change the Nginx configuration
There are no 403-404 errors registered in the site login logs, everything seems to be fine there.
It is noteworthy that when I cleared the cache / cookies in chrome, the site started up, after some time it crashed again, this time cleaning did not help. It still doesn't work on google. Hosting support says that everything is in order on their part, it's in WP. But in what direction to dig?
At the moment, the site opens only in MS Edge, other browsers show errors. I did my best, I really need help!
nginx config:

spoiler
root /home/{username}/domains/{parent_domain};

location ~ /\. {
deny all;
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ ^/wp-admin/includes/ {
deny all;
}

location ~* /wp-includes/js/tinymce/wp-tinymce.php {
allow all;
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php5-{domain}.sock;
}

location ~* /wp-includes/.*\.(php|php3|php4|php5|php6|phps|phtml)$ {
deny all;
}

location ~* /wp-content/.*\.(php|php3|php4|php5|php6|phps|phtml)$ {
deny all;
}

location ~* /modules/.*\.(php|php3|php4|php5|php6|phps|phtml)$ {
deny all;
}

location ~* /skins/.*\.(php|php3|php4|php5|php6|phps|phtml)$ {
deny all;
}

location = /xmlrpc.php {
deny all;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}

location ~* /(?:uploads|files)/.*\.(php|php3|php4|php5|php6|phps|phtml)$ {
deny all;
}

location ~ \.php$ {
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php5-{domain}.sock;
}

UPD: The site stopped opening in any browsers.
Website here
spoiler
radissoncarwash.ru

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Semenov, 2017-12-03
@denisemenov

Try like this.
root /home/{username}/domains/{parent_domain};

index index.php;

location / {
    try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
    include fastcgi.conf;
    fastcgi_intercept_errors on;
    fastcgi_pass unix:/var/run/php5-{domain}.sock;
}

location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires max;
    log_not_found off;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question