你的位置:首页 > 软件开发 > 操作系统 > 【nginx】常见的陷阱和错误

【nginx】常见的陷阱和错误

发布时间:2015-11-19 23:00:04
很多人都可以碰到一个陷阱。下面我们列出,我们经常看到的问题,以及解释如何解决这些问题。在Freenode上的#nginx IRC频道这些讨论很频繁。1、权限从来不要使用777权限,查看目录的权限namei -om /path/to/check2、root设置BAD:server ...

很多人都可以碰到一个陷阱。下面我们列出,我们经常看到的问题,以及解释如何解决这些问题。在Freenode上的#nginx IRC频道这些讨论很频繁。

1、权限

从来不要使用777权限,查看目录的权限

namei -om /path/to/check

2、root设置

BAD:

server {  server_name www.example.com;  location / {    root /var/www/nginx-default/;    # [...]   }  location /foo {    root /var/www/nginx-default/;    # [...]  }  location /bar {    root /var/www/nginx-default/;    # [...]  }}

3、索引设置

BAD:

http {  index index.php index.htm index.html;  server {    server_name www.example.com;    location / {      index index.php index.htm index.html;      # [...]    }  }  server {    server_name example.com;    location / {      index index.php index.htm index.html;      # [...]    }    location /foo {      index index.php;      # [...]    }  }}

4、Using If

if 是邪恶的 参见 If Is Evil

9、FastCGI Path in Script Filename

尽量使用 include fastcgi_params 中的变量,不管什么语言都是一样

GOOD:

fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;

10、Taxing Rewrites

我们应该努力让他们保持整洁。很简单,不添加冗余代码。

BAD:

rewrite ^/(.*)$ http://example.com/$1 permanent;

13、Missing (disappearing) HTTP Headers

If you do not explicitly set underscores_in_headers on, NGINX will silently drop HTTP headers with underscores (which are perfectly valid according to the HTTP standard). This is done in order to prevent ambiguities when mapping headers to CGI variables as both dashes and underscores are mapped to underscores during that process.

17、Using SSLv3 with HTTPS

由于SSLv3的POODLE 漏洞,建议使用在SSL网站禁用,仅仅使用TLS协议代替

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:【nginx】常见的陷阱和错误

关键词:nginx

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

我的浏览记录