|
@@ -0,0 +1,117 @@
|
|
|
+# favicon.ico
|
|
|
+location = /public/favicon.ico {
|
|
|
+ log_not_found off;
|
|
|
+ access_log off;
|
|
|
+ error_log off;
|
|
|
+}
|
|
|
+
|
|
|
+# Disable directory listing
|
|
|
+location / {
|
|
|
+ autoindex off;
|
|
|
+ try_files $uri $uri/ /index.html;
|
|
|
+}
|
|
|
+
|
|
|
+# assets, media, and Static File Caching while allowing safe files
|
|
|
+# 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?)$ {
|
|
|
+# add_header Access-Control-Allow-Origin "*";
|
|
|
+# add_header Cache-Control "public";
|
|
|
+# expires 365d;
|
|
|
+# # 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:
|
|
|
+# access_log on;
|
|
|
+# }
|
|
|
+
|
|
|
+location ~* \.(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?)$ {
|
|
|
+ add_header Access-Control-Allow-Origin "*";
|
|
|
+ add_header Cache-Control "public";
|
|
|
+ expires 365d;
|
|
|
+ # 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:
|
|
|
+ access_log on;
|
|
|
+}
|
|
|
+
|
|
|
+location ~* \.(?:css(\.map)?|js(\.map))$ {
|
|
|
+ expires off;
|
|
|
+ add_header Cache-Control "no-cache";
|
|
|
+ # expires 365d;
|
|
|
+ # 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:
|
|
|
+ access_log on;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+# deny access to .htaccess files
|
|
|
+location ~ /\.ht {
|
|
|
+ deny all;
|
|
|
+ error_log off;
|
|
|
+ log_not_found off;
|
|
|
+}
|
|
|
+
|
|
|
+# Deny access to hidden files (beginning with a period)
|
|
|
+location ~ /\. {
|
|
|
+ deny all;
|
|
|
+ error_log off;
|
|
|
+ log_not_found off;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+location /video/ {
|
|
|
+ # 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.
|
|
|
+ sendfile on;
|
|
|
+ # 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.
|
|
|
+ aio threads;
|
|
|
+ # 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.
|
|
|
+ directio 8m;
|
|
|
+ # This directive assigns a block size value to the data transfer. It related to the directio directive.
|
|
|
+ directio_alignment 1024;
|
|
|
+}
|
|
|
+
|
|
|
+# define error pages
|
|
|
+error_page 401 403 404 /index.html;
|
|
|
+location = /index.html {
|
|
|
+ root /opt/dist;
|
|
|
+ internal;
|
|
|
+}
|
|
|
+
|
|
|
+# redirect server error pages
|
|
|
+error_page 500 502 503 504 /index.html;
|
|
|
+location = / {
|
|
|
+ root /opt/dist;
|
|
|
+ internal;
|
|
|
+}
|
|
|
+
|
|
|
+## Only GET, POST, PUT are allowed##
|
|
|
+if ($request_method !~ ^(GET|PUT|POST)$ ) {
|
|
|
+ return 444;
|
|
|
+}
|
|
|
+## In this case, it does not accept other HTTP method such as HEAD, DELETE, SEARCH, TRACE ##
|
|
|
+
|
|
|
+## Only allow access to these domains/sub-domains samwanekeya.com and localhost
|
|
|
+# if ($host !~ ^(localhost|127.0.0.1|192.168.0.52|192.168.0.163)$ ) {
|
|
|
+# return 444;
|
|
|
+# }
|
|
|
+
|
|
|
+#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.
|
|
|
+#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-
|
|
|
+
|
|
|
+#If you want to enable compression, set the value of this directive to on. By default, it is disabled.
|
|
|
+gzip on;
|
|
|
+# 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.
|
|
|
+gzip_comp_level 2;
|
|
|
+# Set the minimum response length for compression via the content-length response header field. You can set it to more than 20 bytes.
|
|
|
+gzip_min_length 1000;
|
|
|
+gzip_proxied expired no-cache no-store private auth;
|
|
|
+# This directive allows you to choose the response type you want to compress. By default, the response type text/html is always compressed. You can add other response type such as text/plain application/x-javascript text/xml as shown in the code above.
|
|
|
+# gzip_types text/plain application/x-javascript text/xml text/css application/xml;
|
|
|
+# This directive allows you to choose the minimum HTTP version of a request for a compressed response. You can make use of the default value which is 1.1.
|
|
|
+#gzip_http_version 1.1;
|
|
|
+# When gzip directive is enabled, this directive add the header field Vary:Accept Encoding to the response.
|
|
|
+#gzip_vary on;
|
|
|
+# Some browsers such as Internet Explorer 6 do not have support for gzip compression. This directive make use of User-Agent request header field to disable compression for certain browsers.
|
|
|
+#gzip_disable "MSIE [4-6] \.";
|
|
|
+
|
|
|
+# This directive is disabled by default. Enable it if you want implement caching in Nginx. This directive stores metadata of files and directories commonly requested by users.
|
|
|
+open_file_cache max=1000 inactive=30s;
|
|
|
+# This directive contains backup information inside the open_file_cache directive. You can use this directive to set a valid period usually in seconds after which the information related to files and directories is re-validated again.
|
|
|
+open_file_cache_valid 30s;
|
|
|
+# Nginx usually clear information inside the open_file_cache directive after a period of inactivity based on the open_file_cache_min_uses. You can use this directive to set a minimum number of access to identify which files and directories are actively accessed.
|
|
|
+open_file_cache_min_uses 4;
|
|
|
+# You can make use of this directive to allow Nginx to cache errors such as “permission denied” or “can’t access this file” when files are accessed. So anytime a resource is accessed by a user who does not have the right to do so, Nginx displays the same error report “permission denied”.
|
|
|
+open_file_cache_errors on;
|