作为测试,我按照这些文章启用了nginx状态页面
server {
listen 80;
#listen on any host name
server_name _;
location /status {
stub_status on;
access_log off;
}
access_log /var/log/nginx/$host-access.log;
error_log /var/log/nginx/monitor-error.log;
}我通常运行一个wordpress站点,并将任何http请求重定向到https请求:
server {
server_name _;
listen 80;
return 301 https://$host$request_uri;
}我有几个https服务器块,每个dns都有自己的服务器证书。
有没有办法将上面的两个服务器模块结合起来,这样通常情况下,http请求将重定向到https,但是如果使用了/status url,它将激活nginx状态页面?
发布于 2017-11-08 06:27:55
你需要像下面这样做
server {
server_name _;
listen 80;
location = /status {
stub_status on;
access_log off;
}
location / {
return 301 https://$host$request_uri;
}
access_log /var/log/nginx/$host-access.log;
error_log /var/log/nginx/monitor-error.log;
}因此,在/status的情况下,不会发生重定向。在rest情况下,它将只执行https重定向
https://stackoverflow.com/questions/47168317
复制相似问题