官方文档中提供的方法: If you do not want to process requests with undefined "Host" header lines, you may define a default server that just drops the requests: 代码如下: server { listen 80 default_server; server_name _; return 444; } 说白了就是只要是访客用ip访问就直接重置444错误。但是这样好像又不太友好,如果能直接给跳转到该web server的网址就好了。配置如下: 代码如下: server { listen 80 default_server; server_name _; rewrite ^ http://www.domain.com$request_uri?; } 这样还是有一点问题,某些特别的地址,我需要用ip访问,其他的都禁止,如何配置呢?比如说我想让监控宝直接用ip访问我的机器的nginx状态信息,其他的用ip访问的所有请求都跳转到域名上。 代码如下: server { listen 80 default_server; server_name _; location /xxxxx{ stub_status on; access_log off; } location /{ rewrite ^ http://www.domain.com$request_uri?; } } 这样就实现了我们想要的功能了。
最近服务器宕机的现象比较频繁,临下班时分,G给挂掉了,502 Bad Gateway Nginx,不由得让我想起之前的504 Gateway Time-out,两者应该有点联系,一定得弄清楚。Nginx 504 Gateway Time-out的含义是所请求的网关没有请求到,简单来说就是没有请求到可以执行的PHP-CGI。 解决这两个问题其实是需要综合思考的,一般来说Nginx 502 Bad G ···
nginx “nginx could not build the server_names_hash”解决方法 给一个服务器下增加了一些站点别名,差不多有20多个。 重启nginx时候,提示: could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32 解决方法: 在配置文 ···