|
1 |
| -# favicon.ico |
2 |
| -location = /public/favicon.ico { |
3 |
| - log_not_found off; |
4 |
| - access_log off; |
5 |
| - error_log off; |
| 1 | +# assets, media, and static File Caching while allowing safe files |
| 2 | +location ~* \.(?:css(\.map)?|js(\.map)?|ttf|ttc|otf|eot|woff2?|svgz?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv|pdf|docx?|dotx?|docm|dotm|xlsx?|xltx?|xlsm|xltm|pptx?|potx?|pptm|potm|ppsx?)$ |
| 3 | +{ |
| 4 | + add_header Access-Control-Allow-Origin "*"; |
| 5 | + add_header Cache-Control "public"; |
| 6 | + expires 30d; |
| 7 | + # Nginx logs every request that hits the server to a log file. If you use analytics to monitor this, you may want to turn this functionality off. Simply edit the access_log directive: |
| 8 | + access_log off; |
6 | 9 | }
|
7 |
| - |
8 |
| -# assets, media, and Static File Caching while allowing safe files |
9 |
| -location ~* \.(?:css(\.map)?|js(\.map)?|ttf|ttc|otf|eot|woff2?|svgz?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv|pdf|docx?|dotx?|docm|dotm|xlsx?|xltx?|xlsm|xltm|pptx?|potx?|pptm|potm|ppsx?)$ { |
10 |
| - add_header Access-Control-Allow-Origin "*"; |
11 |
| - add_header Cache-Control "public"; |
12 |
| - expires 365d; |
13 |
| - # Nginx logs every request that hits the server to a log file. If you use analytics to monitor this, you may want to turn this functionality off. Simply edit the access_log directive: |
14 |
| - access_log on; |
| 10 | +location /video/ |
| 11 | +{ |
| 12 | + # To utilize operating system resources, set the value of this directive to on. sendfile transfers data between file descriptors within the OS kernel space without sending it to the application buffers. This directive will be used to serve small files. |
| 13 | + sendfile on; |
| 14 | + # This directive enables multi-threading when set to on for write and read operation. Multi-threading is an execution model that allows multiple threads to execute separately from each other whilst sharing their hosting process resources. |
| 15 | + aio threads; |
| 16 | + # This directive improves cache effectiveness by allowing read and write to be sent directly to the application. directio is a filesystem feature of every modern operating system. This directive will be used to serve larger files like videos. |
| 17 | + directio 8m; |
| 18 | + # This directive assigns a block size value to the data transfer. It related to the directio directive. |
| 19 | + directio_alignment 1024; |
15 | 20 | }
|
16 |
| - |
17 |
| -location /video/ { |
18 |
| - # To utilize operating system resources, set the value of this directive to on. sendfile transfers data between file descriptors within the OS kernel space without sending it to the application buffers. This directive will be used to serve small files. |
19 |
| - sendfile on; |
20 |
| - # This directive enables multi-threading when set to on for write and read operation. Multi-threading is an execution model that allows multiple threads to execute separately from each other whilst sharing their hosting process resources. |
21 |
| - aio threads; |
22 |
| - # This directive improves cache effectiveness by allowing read and write to be sent directly to the application. directio is a filesystem feature of every modern operating system. This directive will be used to serve larger files like videos. |
23 |
| - directio 8m; |
24 |
| - # This directive assigns a block size value to the data transfer. It related to the directio directive. |
25 |
| - directio_alignment 1024; |
26 |
| -} |
27 |
| - |
28 | 21 | # define error pages
|
29 |
| -error_page 401 403 404 /index.html; |
30 |
| -location = /index.html { |
31 |
| - root /usr/share/nginx/html; |
32 |
| - internal; |
| 22 | +error_page 401 403 404 /index.html; |
| 23 | +location = /index.html |
| 24 | +{ |
| 25 | + root /usr/share/nginx/html; |
| 26 | + internal; |
| 27 | +} |
| 28 | +# Redirect server error pages |
| 29 | +error_page 500 502 503 504 /index.html; |
| 30 | +location = / |
| 31 | +{ |
| 32 | + root /usr/share/nginx/html; |
| 33 | + internal; |
33 | 34 | }
|
34 |
| - |
35 |
| -# redirect server error pages |
36 |
| -error_page 500 502 503 504 /index.html; |
37 |
| -location = / { |
38 |
| - root /usr/share/nginx/html; |
39 |
| - internal; |
| 35 | +# Log all not found errors for robots.txt but not found notifications |
| 36 | +location = /robots.txt |
| 37 | +{ |
| 38 | + log_not_found on; |
| 39 | + access_log off; |
40 | 40 | }
|
41 |
| - |
42 | 41 | ## Only GET, POST, PUT are allowed##
|
43 |
| -if ($request_method !~ ^(GET|PUT|POST)$ ) { |
44 |
| - return 444; |
| 42 | +if ($request_method !~ ^(GET|PUT|POST)$ ) |
| 43 | +{ |
| 44 | + return 444; |
45 | 45 | }
|
46 | 46 | ## In this case, it does not accept other HTTP method such as HEAD, DELETE, SEARCH, TRACE ##
|
47 |
| - |
48 |
| -## Only allow access to these domains/sub-domains samwanekeya.com and localhost |
49 |
| -if ($host !~ ^(samwanekeya.com|localhost)$ ) { |
50 |
| - return 444; |
51 |
| -} |
52 |
| - |
| 47 | +## Only allow access to these domains/sub-domains kakbima.com and localhost |
| 48 | +#if ($host !~ ^(accounts.kakbima.com|accounts.kakbima.dev|mua.kakbima.co.ke)$ ) |
| 49 | +#{ |
| 50 | +# return 444; |
| 51 | +#} |
53 | 52 | #Gzip can help reduce the amount of network transfer Nginx deals with. However, be careful increasing the gzip_comp_level too high as the server will begin wasting cpu cycles.
|
54 | 53 | #For those using Cloudflare as their CDN this is already taken care of - https://support.cloudflare.com/hc/en-us/articles/200168086-Does-Cloudflare-compress-resources-
|
55 |
| - |
56 | 54 | #If you want to enable compression, set the value of this directive to on. By default, it is disabled.
|
57 | 55 | #gzip on;
|
58 | 56 | # You can make use of this directive to set the compression level. In order not to waste CPU resources, you need not set the compression level too high. Between 1 and 9, you can set the compression level to 2 or 3.
|
|
0 commit comments