我正在使用 Play 框架 2.0。 我正在使用“play dist”创建一个独立的应用程序。
我还使用 Nginx 作为前端。 所以,我有 Nginx 配置:
location /terra {
proxy_pass http://127.0.0.1:9000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
我的路由文件如下所示:
GET / controllers.Application.index()
GET /projects controllers.Application.projects()
当我启动像
这样的应用程序时sh start -Dhttp.address=127.0.0.1 -Dhttp.port=9000
或者只是
sh start
然后转到http://hostnamehere/terra我得到: 未找到请求“GET/terra”的操作
如果我将 GET/controllers.Application.index()
更改为 GET/terra controllers.Application.index()
- 它也不起作用。
此外,当我在本地运行我的应用程序并转到“localhost:9000/WRONG_ROUTING_NAME”时,我收到相同的错误,但我可以看到“这些路由已按此顺序尝试过:”以及方法列表。部署应用程序后,我看不到相同的列表。
当我使用curl myhost.com:9000
时,我得到:curl: (52) Empty returned from server
– Azee 12秒前编辑
最佳答案
问题不在于路由。
如果运行 play dist
,您将获得一个独立的应用程序。但您只能在同一台本地计算机上运行它。似乎“dist”也将一些配置文件复制到某处。如果您想在远程服务器上运行独立应用程序,则必须在该主机上调用 play dist
。
我在 Play 文档中找不到任何相关内容。但我需要这些信息来准备 debian 软件包...
关于deployment - Play 框架 2.0 中的路由不适用于 Nginx 下的独立应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10245839/