代理播放应用程序

时间:2013-10-18 10:18:34

标签: apache proxy playframework playframework-2.1

在我的服务器上,我安装了 Apache HTTP Tomcat ,需要部署我的 Play 应用程序。

我所拥有和工作的 Apache HTTP 服务器的配置是这样的:

/etc/httpd/conf/httpd.conf结束时,我的行代表所有对tomcat的请求。这很好。

ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/

现在,因为我还需要部署我的 Play 应用程序,所以我在上面的最后两行之前添加了以下内容:

<VirtualHost *:80>
    ProxyPreserveHost On
    ServerName localhost
    ProxyPass  /excluded !
    ProxyPass /my_play_app http://localhost:9000/my_play_app
    ProxyPassReverse /my_play_app http://localhost:9000/my_play_app
</VirtualHost>

问题是当我尝试使用此配置访问播放应用程序时,它没有响应。你能给我一些关于如何解决我的问题的提示吗?

提前致谢。

1 个答案:

答案 0 :(得分:1)

多年来,Apache一直以来都做得非常出色,但我发现它可以提供静态资产和反向代理以分离运行的HTTP服务,例如Play应用程序,nginx轻巧,快速,可靠。

我用于Play的nginx配置类似于:

server {
    listen       80;

    # Without this, Play serves the assets from within it's bundled jar. That's
    # fine and works but seems unnecessary when nginx can serve the files directly.
    location /assets {
        alias /app/live/my-play-app-here/active/public;
    }

    location / {
        proxy_pass            http://localhost:9000;
        proxy_set_header      X-Real-IP  $remote_addr;
    }
}

This answer有更多细节。