nginx - Nginx - 位置块配置错误?
问题描述
我在启用站点的 example.conf 中有一个 location 块,应该将 /testing 路由到 503 错误 html 页面,但由于某种原因,它访问了我的应用程序而不是 nginx
[2020-06-30T20:36:13.821768 #6059] FATAL -- : [fc9cb972-f314-4a87-89d9-8334521767b3] ActionController::RoutingError (No route matches [GET] "/testing"):
那是来自我的实际 Rails 应用程序的日志行 - 为什么它甚至比 nginx 路由到我认为我告诉它的地方?
我的 nginx .conf
server { listen 443 ssl;
server_name status.* www.status.*;
# SSL
ssl_certificate_key /etc/nginx/ssl/server_example.com.key;
# logging
access_log /var/log/nginx/status.access.log;
error_log /var/log/nginx/status.error.log;
# security
include security.conf;
# reverse proxy
location / {
if (-f /opt/staytus/staytus/maint.on) {
return 503;
}
port_in_redirect off;
proxy_pass http://example.com:8787/;
}
error_page 503 @maintenance;
location @maintenance {
root /usr/share/nginx/html
rewrite ^(.*)$ /Performing-Maintenace.html;
}
location = /testing/ {
return 500;
}
}
server {
listen 80;
server_name www.status.* status.* 11.22.123.456;
root /opt/staytus/staytus/public;
client_max_body_size 50M;
# SSL
ssl_certificate_key /etc/nginx/ssl/example.com.key;
port_in_redirect off;
return 301 https://example.com$request_uri;
location @puma {
proxy_intercept_errors on;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto http;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://example.com:8787;
}
}
解决方案
推荐阅读
- rest - QAF Dashboard.html 为空
- postgresql - 如何在 Postgres 脚本中使用变量?
- haskell - Haskell Wikibook - 广义代数数据类型练习 - Maybe and Either
- javascript - 从 csv 文件转换为由列名选择的特定列的数组
- javascript - 如何通过javascript或jquery从句子中提取括号内外的文本
- javascript - 订单重复数据删除跟踪代码 woocommerce
- javascript - 循环遍历对象数组并更改值
- html - 简单的
不工作。IDE或浏览器没有错误 - xslt - 节点内提供了 xslt 中的应用模板
- c# - 使用左连接转换 LINQ 内连接