How to add a new directory under domain root?
mfouwaaz
nginx-forum at nginx.us
Thu Dec 29 23:46:19 UTC 2011
Hello
I have a folder titled images folder in www root, intending to hold some
images.
However, the folder is not visible when I try to look at images in it.
e.g.
http://192.168.1.68/imagesfolder/
-- gives a 404 Not Found error.
<img src="http://192.168.1.68/imagesfolder/button-closed.png" width="20"
height="20" alt="myimage" />
-- gives a broken image
The root (/usr/share/nginx/www) works perfectly though. Even the image
shows up clearly if I put it in the root folder.
Do you know how I can fix this/ I have been changing the folder name
and permissions to no avail. I was kind of groping in the dark with the
locations directive too -- I have no much knowledge in that area. I
have pasted the configuration file below. I added the last location
directive shown and then reloaded the configuration file and restarted
nginx as shown. Any guidance is much appreciated.
sudo /etc/init.d/nginx reload
sudo /etc/init.d/nginx restart
Thanks!
Fouwaaz
=====================================================
user www-data;
worker_processes 5;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 2;
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;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# 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/x-javascript text/xml application/xml application/xml+rss
text/javascript;
##
# If HTTPS, then set a variable so it can be passed along.
##
map $scheme $server_https {
default off;
https on;
}
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
if ($uri !~ "^/images/") {
fastcgi_pass 127.0.0.1:9000;
}
}
location ^~ /imagesfolder {
autoindex on;
}
}
}
#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;
# }
#}
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,220689,220689#msg-220689
More information about the nginx
mailing list