Make 1 root file accessible, and serve it for all requests
B.R.
reallfqq-nginx at yahoo.fr
Mon Oct 21 05:01:44 UTC 2013
server {
listen 80;
server_name www.example.com;
root /var/www/mysite;
location / {
# Default location, request will fallback here if none other
location block matches
rewrite ^.*$ / permanent; # Permanent (HTTP 301) redirection to
'root' location '/'
}
location = / {
# 'root' location, will be served by the index directive (which
defaults to the 'index.html' value)
# You could also use '/index.html' and thus not using the index
directive (don't forget to change the rewrite in previous location block)
}
location /css/ {
# Will serve the corresponding directory. Avoid using regex
whenever possible if you can, that'll hopefully save some CPU
}
location /js/ {
# Idem as previous block
}
}
Note 1:
Your configuration includes a
'client_max_body_size<http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size>'
directive.
Its documentation is not very clear as it seems to mix up 'client request
body size' with the 'Content-Length' HTTP header field which represents the
'answer body size', the size of the file sent after the answer header.
I just checked my own configuration to be sure (I serve files bigger than 1
MiB), but I guess you don't need this directive to serve any file, whatever
its size.
Note 2:
Check the directives in the parent 'http' block to ensure that no
'autoindex<http://nginx.org/en/docs/http/ngx_http_autoindex_module.html#autoindex>'
directive is to be found or if it is, that it is set to 'off'. When not
set, it defaults to 'off'.
Check also there that the
'index<http://nginx.org/en/docs/http/ngx_http_index_module.html#index>'
directive is not set since all you want is the default 'index.html' value.
You can override it in your server block if you need another value at the
'http' block level.
---
*B. R.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20131021/44d29a8f/attachment.html>
More information about the nginx
mailing list