瀏覽代碼

nginx

master
Chris Smith 4 年之前
父節點
當前提交
8bf17bb9e2
簽署人: Chris Smith <chris@chameth.com> GPG Key ID: 3A2D4BBDC4A3C9A9
共有 1 個文件被更改,包括 34 次插入0 次删除
  1. 34
    0
      content/docs/software/nginx.adoc

+ 34
- 0
content/docs/software/nginx.adoc 查看文件

@@ -0,0 +1,34 @@
1
+:source-highlighter: pygments
2
+:source-language: nginx
3
+
4
+== Nginx
5
+
6
+=== Redirecting image requests to webp versions
7
+
8
+[source]
9
+----
10
+http {
11
+    map $http_accept $webp_suffix {
12
+        "~*webp"  ".webp";
13
+    }
14
+
15
+    server {
16
+        location ~ \.(png|jpe?g)$ {
17
+            try_files $uri$webp_suffix $uri =404;
18
+            expires 1y;
19
+        }
20
+    }
21
+}
22
+----
23
+
24
+=== Redirecting to a canonical domain
25
+
26
+Instead of complex rules to redirect certain requests, just add a separate `server` block:
27
+
28
+[source]
29
+----
30
+server {
31
+    server_name www.example.com;
32
+    return 301 $scheme://example.com$request_uri;
33
+}
34
+----

Loading…
取消
儲存