I im trying to configure nginx to serve images on request. Consider the following config below;
sites-available/images.conf
server {
listen 8888;
server_name localhost;
location images {
root html/uploads;
}
}
nginx.conf
... ommitted ...
http {
include 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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
... ommitted ...
include sites-available/*.conf;
}
...ommitted..
Now, when i try to access http://localhost:8888/images
, it will output 404 Not Found
and the error logs
2018/09/01 17:01:30 [error] 10368#9796: *1 "C:\nginx-1.14.0/html/images/index.html" is not found (3: The system cannot find the path specified), client: 127.0.0.1, server: localhost, request: "GET /images/ HTTP/1.1", host: "localhost:8888"
Note that i have a folder inside html called "uploads". So i expected nginx to serve C:\nginx-1.14.0/html/uploads/index.html
but it does not. I don't understand why it won't point to the correct folder which is html/uploads
.
Aucun commentaire:
Enregistrer un commentaire