Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Serving static files:
- # If Nginx could not find the file it will return a 404 page to the user by default.
- # But you also can return the directory listing by using autoindex directive
- server {
- # `root` directive append URI to the root and then tries to return a file.
- root /var/www/data;
- autoindex on;
- location / {
- # In this location `root` directive is inherited from its parent section which is `server`
- }
- # Request: GET /images/a.png
- # - Now Nginx tries to find images in this path: /var/www/data/images/a.png
- # Request: GET /images/a/b
- # - Now Nginx tries to serve this file: /var/www/data/images/a/b/index.html
- location /images/ {
- # In this location `root` directive is inherited from its parent section which is `server`
- }
- # GET /anything/a.mp3
- # - If URI ends with .mp3 or .mp4 nginx tries to file the file in this path: /var/www/media/
- # - In this exmaple it tries to serve /var/www/media/a.mp3
- location ~ \.(mp3|mp4) {
- root /var/www/media;
- }
- }
Add Comment
Please, Sign In to add comment