Welcome! Log In Create A New Profile

Advanced

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

B.R.
October 21, 2013 01:04AM
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.*
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

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

Jonah October 20, 2013 11:58PM

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

B.R. October 21, 2013 01:04AM

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

Jonah October 21, 2013 06:23AM

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

B.R. October 21, 2013 10:24AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 299
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready