diff --git a/docs/nginx.html b/docs/nginx.html index 35d70e96..85f1eccc 100644 --- a/docs/nginx.html +++ b/docs/nginx.html @@ -37,10 +37,12 @@
这个 nginx 快速参考备忘单显示了它的常用命和配置使用清单。
sudo systemctl status nginx # nginx当前状态
sudo systemctl reload nginx # 重新加载 nginx
sudo systemctl restart nginx # 重启nginx
+
sudo nginx -t # 检查语法
nginx # 启动
nginx -s reload # 重启
@@ -48,16 +50,16 @@
nginx -s quit # 平滑关闭nginx
nginx -V # 查看nginx的安装状态,
+docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
+
location / {
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
proxy_set_header Host $host;
- # 客户端的 IP 地址
- proxy_set_header X-Real-IP $remote_addr;
- # HTTP 请求端真实的IP
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ (.git|.gitattributes|.gitignore|.svn) {
+
通用备份和归档文件
+location ~* "\.(old|orig|original|php#|php~|php_bak|save|swo|aspx?|tpl|sh|bash|bak?|cfg|cgi|dll|exe|git|hg|ini|jsp|log|mdb|out|sql|svn|swp|tar|rdf)$" {
deny all;
}
+拒绝访问 .git
和 .svn
目录
location ~ (.git|.svn) {
+ deny all;
+}
+
+
+拒绝访问隐藏文件和目录
+location ~ /\.(?!well-known\/) {
+ deny all;
+}
+
location ~ \/public\/(css|js|img)\/.*\.(js|css|gif|jpg|jpeg|png|bmp|swf) {
@@ -779,9 +793,48 @@
}
}
+location ~* "(base64_encode)(.*)(\()" {
+ deny all;
+}
+
+location ~* "(eval\()" {
+ deny all;
+}
+
+gzip on;
+gzip_buffers 16 8k;
+gzip_comp_level 6;
+gzip_http_version 1.1;
+gzip_min_length 256;
+gzip_proxied any;
+gzip_vary on;
+gzip_types
+ text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
+ text/javascript application/javascript application/x-javascript
+ text/x-json application/json application/x-web-app-manifest+json
+ text/css text/plain text/x-component
+ font/opentype application/x-font-ttf application/vnd.ms-fontobject
+ image/x-icon;
+gzip_disable "msie6";
+
+add_header X-Robots-Tag "noindex";
+
+location = /robots.txt {
+ return 200 "User-agent: *\nDisallow: /\n";
+}
+