M
M
Multigame2015-03-25 10:40:33
Nginx
Multigame, 2015-03-25 10:40:33

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"

configs
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;
}

Directory permissions
[[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

Tell me what could be the problem...

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
Andrei, 2015-03-25
@Multigame

Perhaps the reason is in selinux, since the directory is not standard. getenforceto check the status.
The current SElinux context file can be viewed with ls -Z /srv/r/index.htmland
set to the appropriate
chcon -Rv --type=httpd_sys_content_t /srv/rone.

W
wdcloud, 2019-02-04
@wdcloud

SElinux and firewall possible if simpler steps didn't help
https://www.nginx.com/blog/using-nginx-plus-with-s...
https://linuxize.com/post/how-to-stop -and-disable-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question