-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.nginx.conf
60 lines (37 loc) · 2.13 KB
/
test.nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
http{
include mime.types;
server{
listen 80;
location / {
# root directive sets the root directory for requests, i.e. nginx will search the given directory for that request.
# File is served from the path created by appending the incoming URI to the value of the root directive
root /var/www/mysite; # Here, the `/var/www/mysite/index.html` file will be sent in response to the “/index.html” (or, "/") request.
}
location /fruits {
root /var/www/mysite; # for this request, nginx will search this directory.
index fruit-list.html; # Telling nginx that the `/var/www/mysite/fruits/fruit-list.html` file will be sent in response to "/fruits".
# since, no index.html is present, "/fruits/index.html" will cause a 404 error.
}
location /nutritious-fruits {
alias /var/www/mysite/fruits;
index fruit-list.html; # since, index.html is not present in /var/www/mysite/fruits, so we need to set the index.
# on request of `/nutritious-fruits/apple.png`, the file '/var/www/mysite/fruits/apple.png' will be sent.
# on request of `/nutritious-fruits`, the file '/var/www/mysite/fruits/fruit-list.html' will be sent.
# i.e. we don't need to have a separate directory as previous case. Basically, we are using the contents of `/fruits` route for `/nutritious-fruits` as well.
}
location /vegetables{
root /var/www/mysite;
# The path to a file is constructed appending the file mentioned to the root directive
try_files $uri $uri/ /vegetables/veggies.html /vegetables/potato.html =404;
# Initially, nginx will look for "/var/www/mysite/vegetables/veggies.html" and then
# "/var/www/mysite/vegetables/potato.html". If no file is found, we would get a 404 response.
}
location /numbers {
rewrite ^/numbers/(\d)$ /count/$1 last;
}
location ~* /count/[0-9] {
return 301 /;
}
}
}
events{}