网上搜索到的是在配置文件中添加:
optimize_server_names off;
server_name_in_redirect off;
但在nginx0.8.38中提示:
Restarting nginx: [warn]: the "optimize_server_names" directive is deprecated, use the "server_name_in_redirect" directive instead in /etc/nginx/nginx.conf:44
[emerg]: "server_name_in_redirect" directive is duplicate in /etc/nginx/nginx.conf:45
configuration file /etc/nginx/nginx.conf test failed
大意是说:
optimize_server_names已经被弃用,只用server_name_in_redirect即可。
因此,只需在nginx.conf中添加以下一行即可。
server_name_in_redirect off;