我一直在研究和阅读几乎所有通过网络搜索呈现给我的东西。这似乎是一个简单的然而,我无法解决这个痛苦。
我让负载均衡器检查来自AWS中所有节点的200OK
响应作为健康检查。因此,在nginx conf (/etc/nginx/conf.d/ssl.conf
)中,我有以下条目作为位置块
location /about {
root /usr/share/nginx/html;
add_header X-Frame-Options "DENY";
try_files $uri /about.htm;
}
文件/usr/share/nginx/html/about.htm
存在。因此,我们的想法是,当有人对https://server_name/about
执行GET操作时,将显示文件/usr/share/nginx/html/about.htm
的内容。它在nginx 1.0.15上工作,我升级到nginx version: nginx/1.8.0
,从那时起它开始工作。nginx的错误日志显示了以下无限循环
2015/10/09 23:20:24 [error] 25078#0: *308 rewrite or internal redirection cycle while internally redirecting to "/about.html", client: 10.22.32.108, server: server_name, request: "GET /about HTTP/1.1", host: "10.22.32.72"
由于此URL (..../about)失败,健康检查失败,因此没有流量发送到此节点。
建议吗? ?
我在nginx中看到了许多与try_files
指令相关的问题&每个人对这个混蛋都有独特的看法。所以,我在/etc/nginx/conf.d
viz default.conf
下有2个nginx配置文件-其中有HTTP流量的配置文件和ssl.conf
-其中有HTTPS流量的配置文件。在我的例子中,/etc/nginx/conf.d/default.conf
被配置为将任何HTTP请求重定向到HTTPS, /etc/nginx/conf.d/ssl.conf
负责HTTPS事务。
从nginx.org repo安装nginx 1.8后(我在nginx 1.0.15上,它在EPEL repo中可用)。EPEL没有更新的版本,太糟糕了!我需要修改我的厨师食谱nginx现在)。http://server_name/about
&https://server_name/about
开始断裂。
下面是安装1.8之前的原始配置文件(只有相关的位置块i,e /about
)
default.conf & ssl.conf
在此位置有相同的配置/about
location /about {
add_header X-Frame-Options "DENY";
try_files $uri /about.html;
}
因此,在1.8版本中,我必须这样更改(在两个文件中)
location /about {
root /usr/share/nginx/html;
add_header X-Frame-Options "DENY";
try_files $uri /about.html;
}
注意root
, nginx 1.8似乎期望nginx的$ROOT_DIRECTORY。以下是nginx
Checks the existence of files in the specified order and uses the first found file for request processing; the processing is performed in the current context. The path to a file is constructed from the file parameter according to the root and alias directives.
所以在/etc/nginx/conf.d/ssl.conf
中设置了这个之后,在/etc/nginx/conf.d/default.conf
中遗漏了根指令。