Answer the question
In order to leave comments, you need to log in
How to defeat Permission denied in nginx?
Good afternoon.
many times already set nginx there were no problems ... and then suddenly, when changing the site directory, a 403 error starts to pour in the logs
2015/03/25 10:34:40 [error] 8068#0: *1 open() "/srv/r/index.html" failed (13: Permission denied), client: 210.30.41.30, server: 185.16. 104.16, request: "GET /index.html HTTP/1.1", host: "185.16.104.16"
2015/03/25 10:34:43 [error] 8068#0: *1 "/srv/redstar/index.html " is forbidden (13: Permission denied), client: 210.30.41.30, server: 185.16.104.16, request: "GET / HTTP/1.1", host: "185.16.104.16"
server {
listen 80;
server_name 185.16.104.16;
location / {
root /srv/r;
index index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /srv/r;
}
}
user apache;
worker_processes 1;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log;
proxy_read_timeout 800;
proxy_connect_timeout 800;
proxy_send_timeout 800;
client_max_body_size 50m;
client_body_buffer_size 128k;
client_header_buffer_size 32k;
large_client_header_buffers 2 2k;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
server_names_hash_bucket_size 1024;
include /etc/nginx/conf.d/*.conf;
}
[[email protected] ]# cd /srv/r
[[email protected] r]# ls -lsah
total 48K
4.0K drwxrwxrwx. 2 apache apache 4.0K Mar 25 10:24 .
4.0K drwxr-xr-x. 3 apache apache 4.0K Mar 25 09:25 ..
20K -rwxrwxrwx. 1 apache apache 17K Jan 21 12:30 50x.html
20K -rwxrwxrwx. 1 apache apache 19K May 14 2012 index.html
Answer the question
In order to leave comments, you need to log in
Perhaps the reason is in selinux, since the directory is not standard. getenforce
to check the status.
The current SElinux context file can be viewed with ls -Z /srv/r/index.html
and
set to the appropriate chcon -Rv --type=httpd_sys_content_t /srv/r
one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question