The OpenNET Project / Index page

[ новости /+++ | форум | wiki | теги | ]



"403 Forbidden при заходе на сервер"
Вариант для распечатки  
Пред. тема | След. тема 
Форум WEB технологии (nginx)
Изначальное сообщение [ Отслеживать ]

"403 Forbidden при заходе на сервер"  +/
Сообщение от evgeniy123 email(ok) on 01-Май-18, 14:29 
Хочу развернуть только на NGINX проект, но каждый раз получаю ошибку  403 Forbidden  при заходе на сервер. понять не могу почему так.
nginx/error.log

....
2018/05/01 04:45:43 [error] 1243#1243: *21 directory index of "/var/www/kebab/frontend/web/" is forbidden, client:
...

Сделал так:


chown www-data -R /var/www/kebab
chmod 777 -R /var/www/kebab

ps -ef|grep nginx

root      1242     1  0 Apr30 ?        00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data  1243  1242  0 Apr30 ?        00:00:00 nginx: worker process
root      2545  2364  0 05:19 pts/0    00:00:00 grep --color=auto nginx      


nginx.conf:


user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";
        
      include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;    
        
        
        

/etc/nginx/site-enable/kebab


# Implement upstream connection to PHP-FPM
# "phpfpm" here is a name for this upstream connection, which you can customize
# I create a custom upstream connection per vhost, to better segregate PHP processes by vhost
# To do the same, you need a unique upstream name, and a unique filename for your php5-fpm.sock file
upstream phpfpm {
    server unix:/var/run/php5-fpm.sock;
    #avoid sockets for nginx-fpm on Linux, they are good for BSD
    server 127.0.0.1:9000;
}

server {
    listen 80;
    server_name 85.203.117.20;

    set $base_root /var/www/kebab;
    root $base_root;

    access_log  /var/log/nginx/access.log;
    error_log   /var/log/nginx/error.log;

    #error_log /var/log/nginx/advanced.local.error.log warn;
    #access_log /var/log/nginx/advanced.local.access.log main;
    charset UTF-8;
    index index.php index.html;

    location / {
        root $base_root/frontend/web;
        try_files $uri $uri/ /frontend/web/index.php$is_args$args;

        # omit static files logging, and if they don't exist, avoid processing by Yii (uncomment if necessary)
        #location ~ ^/.+\.(css|js|ico|png|jpe?g|gif|svg|ttf|mp4|mov|swf|pdf|zip|rar)$ {
        #    log_not_found off;
        #    access_log off;
        #    try_files $uri =404;
        #}

        location ~ ^/assets/.+\.php(/|$) {
            deny all;
        }
    }
                                                      
                                                      
             location /admin {
        alias $base_root/backend/web/;

        # redirect to the URL without a trailing slash (uncomment if necessary)
        #location = /admin/ {
        #    return 301 /admin;
        #}

        # prevent the directory redirect to the URL with a trailing slash
        location = /admin {
            # if your location is "/backend", try use "/backend/backend/web/index.php$is_args$args"
            # bug ticket: https://trac.nginx.org/nginx/ticket/97
            try_files $uri /backend/web/index.php$is_args$args;
        }

        # if your location is "/backend", try use "/backend/backend/web/index.php$is_args$args"
        # bug ticket: https://trac.nginx.org/nginx/ticket/97
        try_files $uri $uri/ /backend/web/index.php$is_args$args;

        # omit static files logging, and if they don't exist, avoid processing by Yii (uncomment if necessary)
        #location ~ ^/admin/.+\.(css|js|ico|png|jpe?g|gif|svg|ttf|mp4|mov|swf|pdf|zip|rar)$ {
        #    log_not_found off;
        #    access_log off;
        #    try_files $uri =404;
        #}

        location ~ ^/admin/assets/.+\.php(/|$) {
            deny all;
        }
    }                          

    location ~ ^/.+\.php(/|$) {
        rewrite (?!^/((frontend|backend)/web|admin))^ /frontend/web$uri break;
        rewrite (?!^/backend/web)^/admin(/.+)$ /backend/web$1 break;

        fastcgi_pass 127.0.0.1:9000; # proxy requests to a TCP socket
        #fastcgi_pass unix:/var/run/php-fpm.sock; # proxy requests to a UNIX domain socket (check your www.conf file)
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        try_files $fastcgi_script_name =404;
    }

    location ~ /\. {
        deny all;
    }
}                  

S NGINX не работают плотно

Ответить | Правка | Cообщить модератору

Оглавление

Сообщения по теме [Сортировка по времени | RSS]


1. "403 Forbidden при заходе на сервер"  +/
Сообщение от ACCA (ok) on 01-Май-18, 22:46 
Вместо
        try_files $uri $uri/ /frontend/web/index.php$is_args$args;

Напиши:
        try_files $uri $uri/ index.php$is_args$args;

Ответить | Правка | ^ к родителю #0 | Наверх | Cообщить модератору

2. "403 Forbidden при заходе на сервер"  +/
Сообщение от universite (ok) on 02-Май-18, 00:48 
Положите в /var/www/kebab/frontend/web/ пустой index.php
Ответить | Правка | ^ к родителю #0 | Наверх | Cообщить модератору

3. "403 Forbidden при заходе на сервер"  +/
Сообщение от evgeniy123 email(ok) on 02-Май-18, 00:51 
> Положите в /var/www/kebab/frontend/web/ пустой index.php

Решилась. Всем спасибо

Ответить | Правка | ^ к родителю #2 | Наверх | Cообщить модератору

Архив | Удалить

Рекомендовать для помещения в FAQ | Индекс форумов | Темы | Пред. тема | След. тема




Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру