【发布时间】:2015-12-22 12:15:08
【问题描述】:
这是我的 nginx 配置
server {
listen 80;
server_name localhost;
root /home/user/app/public;
try_files $uri/index.html $uri @app;
location @app {
proxy_pass http://app;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
假设我的公共 ip:111.111.111.111
当我尝试输入站点 111.111.111.111/path 时,它工作正常,但是当我尝试仅输入根 url 111.111.111.111 时,它给了我“欢迎使用 nginx”消息。我查看了nginx日志,但是没有关于root url的内容。
我也在使用独角兽,但我认为这没有问题,我假设我已经在此处添加了必要的配置部分。
【问题讨论】:
-
“欢迎使用 nginx”应该是 nginx 安装的默认 index.html。您确实在
try_files中有$uri/index.html作为第一个,这是您的意图吗?您可以删除/重命名 index.html 或在 try_files 中删除/重命名它 - 这会改变行为吗? -
我已将其删除,但没有任何变化。我不明白为什么 nginx 日志中也没有任何内容
-
@RamazanZor 试试
location / { try_files $uri/index.html $uri @app; } -
它不起作用,有趣的是,即使我在根 url 中停止 nginx 服务,它仍然显示“欢迎使用 nginx”消息
-
我找到了问题,只是浏览器缓存的问题,我删除了问题解决了
标签: ruby-on-rails ruby-on-rails-4 nginx web-deployment