Nginx 403错误:[文件夹]的目录索引被禁止(检查用户权限)

时间:2019-02-10 13:10:19

标签: nginx web-config hexo

1。这是nginx文件夹的树。 / home / git / blog / hexo是我放置博客文件的地方

├── conf.d
├── fastcgi.conf
├── fastcgi_params
├── koi-utf
├── koi-win
├── mime.types
├── nginx.conf
├── proxy_params
├── scgi_params
├── sites-available
│   └── default
├── sites-enabled
│   └── default -> /etc/nginx/sites-available/default
├── snippets
│   ├── fastcgi-php.conf
│   └── snakeoil.conf
├── uwsgi_params
└── win-utf

2。进程“ nginx”的用户,显示该用户为git。

root@ubuntu:/etc/nginx# ps aux | grep nginx 
root     14931  0.0  0.7 125108  3968 ?        Ss   06:25   0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
git      15108  0.0  0.6 125456  3144 ?        S    07:38   0:00 nginx: worker process
root     15361  0.0  0.1  12944  1016 pts/0    S+   07:44   0:00 grep --color=auto ngin

3。nginx的状态,表明一切正常

root@ubuntu:/etc/nginx# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-02-10 06:25:33 EST; 1h 20min ago
Process: 14918 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 14927 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 14924 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 14931 (nginx)
Tasks: 2
Memory: 1.9M
CPU: 70ms
CGroup: /system.slice/nginx.service
    ├─14931 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
    └─15108 nginx: worker process  



ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server...
ubuntu systemd[1]: nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument
ubuntu systemd[1]: Started A high performance web server and a reverse proxy server.

4。niginx的错误日志:

directory index of "/home/git/blog/hexo/" is forbidden, client: ip, server: ip, request: "GET / HTTP/1.1", host: "myhost.com"

5。nginx.conf的详细信息

root@ubuntu:/etc/nginx# cat nginx.conf 
user git;
worker_processes auto;
pid /run/nginx.pid;

events {
worker_connections 768;

}

http {

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

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

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

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

gzip on;
gzip_disable "msie6";

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

6。网站启用/默认的详细信息

server {
listen 80 default_server;
listen [::]:80 default_server;

root /home/git/blog/hexo;

index index.html index.htm index.nginx-debian.html;

server_name ip of myhost.com;

location / {
    try_files $uri $uri/ =404;
}

}
  1. 背景:

我正在使用hexo和nginx来建立博客,并且当我在本地(在Linux上)运行“ hexo d -g”时,它工作正常。但是myhost.com显示403禁止访问。

我尝试了其他人在stackoverflow上提供的解决方案,但它们都不对我有用。您能给我一些建议吗?谢谢!

0 个答案:

没有答案