|
|
第1行: |
第1行: |
| <pre>
| |
|
| |
|
| ng 配置下下
| | =test the healthiness of the Nginx container= |
| | https://blog.csdn.net/qq_16240085/article/details/114126981 |
|
| |
|
| location /websocket/ {
| |
| #internal;
| |
|
| |
| #if ( $http_sec_websocket_protocol = "" ) {
| |
| # return 400;
| |
| #}
| |
|
| |
|
| | | [[category:devops]] [[category:interview]] |
| websocket 404 的原因
| |
| | |
| | |
| internal
| |
| 语法:internal
| |
| 默认值:no
| |
| 使用字段: location
| |
| internal指令指定某个location只能被“内部的”请求调用,外部的调用请求会返回”Not found” (404)
| |
| “内部的”是指下列类型:
| |
| • 指令error_page重定向的请求。
| |
| • ngx_http_ssi_module模块中使用include virtual指令创建的某些子请求。
| |
| • ngx_http_rewrite_module模块中使用rewrite指令修改的请求。
| |
| 一个防止错误页面被用户直接访问的例子:
| |
| error_page 404 /404.html;
| |
| location /404.html {
| |
| internal;
| |
| }
| |
| | |
| | |
| 常用场景
| |
| Nginx 的 internal 指令可以用来限制 Web 公共目录下的图片等资源文件被任意用户直接访问。一个明显的使用场景是,对于用户上传的认证图片,属于个人隐私资源,不应该让所有用户都能访问得到,通常只能由管理员审核时查看。
| |
| | |
| 假定需要限制访问的图片的 URL 路径是 /images/auth-pictures/,Nginx 进行如下配置:
| |
| | |
| location ^~ /images/auth-pictures/ {
| |
| internal;
| |
| }
| |
| 重启 Nginx,直接访问 /images/auth-pictures/ 下的图片,会返回 404:
| |
| | |
| | |
| </pre>
| |
| | |
| | |
| | |
| [https://www.cnblogs.com/imzhi/p/nginx-restrict-access-with-internal-directive.html Nginx internal 指令限制访问图片资源文件] | |
| | |
| | |
| [https://segmentfault.com/a/1190000002797606 nginx配置location总结及rewrite规则写法]
| |
| | |
| [[category:nginx]] | |
2022年6月7日 (二) 06:34的最新版本