nginx 403错误提示:目录索引>“/home/deploy/my_app/current/public/”是禁止的

xmd2e60i  于 2023-10-17  发布在  Nginx
关注(0)|答案(2)|浏览(115)

环境:

数字海洋Ubuntu 18.04 droplet,nginx安装,应用程序在Ruby on Rails中,使用capistrano进行部署。(它使用一个名为deploy的用户)
之前一切都很正常我在Digital Ocean上收到消息,然后我在Digital Ocean Ubuntu 18.04 LTS服务器上升级了一些软件包。从那时起,该网站已被打破,我得到403错误
使用$nginx -V,我验证了版本从1.12.2升级到1.18.0
403 forbidden error

$sudo tail /var/log/nginx/error.log显示以下错误。

2021/01/11 21:58:55 [error] 5678#5678:1禁止目录索引“/home/deploy/my_app/current/public/”,客户端:999.888.255.141,服务器:. myserver.com,request:“GET / HTTP/2.0”,host:“网址:hmm.myserver.com“

/etc/nginx/sites-available/default文件:

server {
        listen 80;
        listen [::]:80;
        server_name *.myserver.com;
        return 301 https://$host$request_uri;
}
server {
        listen 443 ssl http2;
        server_name *.myserver.com;
        passenger_enabled on;
        rails_env    production;
        root         /home/deploy/my_app/current/public;
        ssl_certificate /home/deploy/letsencrypt/fullchain.pem;
        ssl_certificate_key /home/deploy/letsencrypt/privkey.pem;

        # redirect server error pages to the static page /50x.html

}

$ sudo view 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 TLSv1.3; # 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_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Phusion Passenger config
        ##
        # Uncomment it if you installed passenger or passenger-enterprise
        ##

        # include /etc/nginx/passenger.conf;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

$什么ruby

/home/deploy/.rbenv/shims/ruby

这将显示为:

Version: 6.0.7
Date   : 2021-01-11 23:58:57 +0000
------------- Apache processes -------------
*** WARNING: The Apache executable cannot be found.
Please set the APXS2 environment variable to your 'apxs2' executable's filename, or set the HTTPD environment variable to your 'httpd' or 'apache2' executable's filename.

--------- Nginx processes ----------
PID   PPID  VMSize    Private  Name
------------------------------------
6884  1     175.0 MB  0.7 MB   nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
6885  6884  175.2 MB  0.8 MB   nginx: worker process
### Processes: 2
### Total private dirty RSS: 1.47 MB

--- Passenger processes ---

### Processes: 0
### Total private dirty RSS: 0.00 MB

$ ps辅助|grep nginx显示为:

root      6884  0.0  0.1 179176  5712 ?        Ss   Jan11   0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data  6885  0.0  0.3 179436 11352 ?        S    Jan11   0:00 nginx: worker process
deploy    8438  0.0  0.0  12940  1012 pts/0    S+   00:24   0:00 grep --color=auto nginx

$ ps辅助|grep passenger显示为:

deploy    8478  0.0  0.0  12940   936 pts/0    S+   00:29   0:00 grep --color=auto passenger

我重启了几次nginx。我也试过重新安装Rails应用程序。
我找到this link了。参见“权限被拒绝”部分。但在我的服务器上,没有文件/Users/phusion/Sites/rack.test。实际上,服务器甚至根本没有/Users或/Users/phpages文件夹。
我是个新手。任何帮助解决这个403错误是非常感谢。

wqlqzqxt

wqlqzqxt1#

建议不多。
您可以检查您的乘客安装的路径与

passenger-config --root

然后与nginx. conf中引用的比较。
还有,
确认您在/home/deploy/my_app/current/public/上具有正确的权限和所有权

jdg4fx2g

jdg4fx2g2#

问题解决了。
在nginx.conf文件中,下面这行需要取消注解。

##
# Phusion Passenger config
##
# Uncomment it if you installed passenger or passenger-enterprise
##

include /etc/nginx/passenger.conf;

相关问题