I want to use nginx for file browsing (like in file explorer- have no index.html)
folder /opt/chocolatey content:
find
.
./ccleaner
./ccleaner/ccsetup549.exe
configuration file:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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 main;
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;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
#root /usr/share/nginx/html;
root /opt/chocolatey/;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
#location / {
#}
location / {
root /opt/chocolatey/;
autoindex on;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Permissions: chmod 755 /opt/chocolatey/* chown -R nginx:nginx /opt/chocolatey
ls -ls
total 4
4 drwxr-xr-x. 4 nginx nginx 4096 Nov 27 08:29 chocolatey
In error.log file:
request: "GET / HTTP/1.1", host: "192.168.1.13" 2018/11/27 08:44:21 [error] 9733#0: *2 directory index of "/opt/chocolatey/" is forbidden
Selinux disabled
Set chmod -R o+x /opt/chocolatey
Solved:had to change config file:
Removed:
location / {
root /opt/chocolatey/;
autoindex on;
}
added
root /opt/chocolatey/;
autoindex on;
Under server { } directives
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.