Make 1 root file accessible, and serve it for all requests

B.R. reallfqq-nginx at
Mon Oct 21 05:01:44 UTC 2013

server {
    listen 80;

    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
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
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
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: <>

More information about the nginx mailing list