如何在apache中为mac os x上的play framework web app设置反向代理

use*_*194 3 macos reverse-proxy apache2 playframework playframework-2.0

我正在尝试将带有反向代理的apache前端添加到端口9000上的播放框架应用程序.我已根据播放文档尝试了以下httpd配置:http://www.playframework.org/documentation/2.0. 2/HttpServer的

<VirtualHost *:80>
  ProxyPreserveHost On
  ServerName http://localhost
  ProxyPass / http://127.0.0.1:9000/
  ProxyPassReverse / http://127.0.0.1:9000/
  LogLevel debug
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

我只加载了mod_proxy模块,但已注释掉所有其他代理相关模块(http,ajp,jk等).

当我尝试点击时http://localhost,我在错误日志中得到以下内容:

[debug] mod_proxy_ajp.c(45): proxy: AJP: canonicalising URL //localhost:8009/
[debug] proxy_util.c(1506): [client ::1] proxy: ajp: found worker ajp://localhost:8009/ for ajp://localhost:8009/
[debug] mod_proxy.c(1015): Running scheme ajp handler (attempt 0)
[debug] mod_proxy_http.c(1963): proxy: HTTP: declining URL ajp://localhost:8009/
[debug] mod_proxy_ajp.c(672): proxy: AJP: serving URL ajp://localhost:8009/
[debug] proxy_util.c(1949): proxy: AJP: retrying the worker for (localhost)
[error] proxy: AJP: disabled connection for (localhost)
[debug] mod_proxy_ajp.c(45): proxy: AJP: canonicalising URL //localhost:8009/favicon.ico
[debug] proxy_util.c(1506): [client ::1] proxy: ajp: found worker ajp://localhost:8009/ for ajp://localhost:8009/favicon.ico
[debug] mod_proxy.c(1015): Running scheme ajp handler (attempt 0)
[debug] mod_proxy_http.c(1963): proxy: HTTP: declining URL ajp://localhost:8009/favicon.ico
[debug] mod_proxy_ajp.c(672): proxy: AJP: serving URL ajp://localhost:8009/favicon.ico
[debug] proxy_util.c(1949): proxy: AJP: retrying the worker for (localhost)
[error] proxy: AJP: disabled connection for (localhost)
Run Code Online (Sandbox Code Playgroud)

当我使用apachectl查看已加载的模块时,我看到了这个:

Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 authn_file_module (shared)
 authz_host_module (shared)
 cache_module (shared)
 disk_cache_module (shared)
 dumpio_module (shared)
 reqtimeout_module (shared)
 ext_filter_module (shared)
 include_module (shared)
 filter_module (shared)
 substitute_module (shared)
 deflate_module (shared)
 log_config_module (shared)
 log_forensic_module (shared)
 logio_module (shared)
 env_module (shared)
 mime_magic_module (shared)
 cern_meta_module (shared)
 expires_module (shared)
 headers_module (shared)
 ident_module (shared)
 usertrack_module (shared)
 setenvif_module (shared)
 version_module (shared)
 proxy_module (shared)
 mime_module (shared)
 dav_module (shared)
 autoindex_module (shared)
 asis_module (shared)
 info_module (shared)
 cgi_module (shared)
 dav_fs_module (shared)
 vhost_alias_module (shared)
 negotiation_module (shared)
 dir_module (shared)
 imagemap_module (shared)
 actions_module (shared)
 speling_module (shared)
 alias_module (shared)
 rewrite_module (shared)
 apple_userdir_module (shared)
 bonjour_module (shared)
 authn_dbm_module (shared)
 authn_anon_module (shared)
 authn_dbd_module (shared)
 authn_default_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_dbm_module (shared)
 authz_owner_module (shared)
 authz_default_module (shared)
 mem_cache_module (shared)
 dbd_module (shared)
 status_module (shared)
 proxy_http_module (shared)
 proxy_ajp_module (shared)
Syntax OK
Run Code Online (Sandbox Code Playgroud)

因此,即使我将它们注释掉,proxy_http和proxy_ajp也都会被加载.我正在尝试使用运行osx lion的mac上的apache(2.2.21).关于这里有什么问题的任何想法?

bie*_*ior 6

尝试使用除localhost之外的其他名称,即:

<VirtualHost *:80>
  ProxyPreserveHost On
  ServerName myproject.loc
  ProxyPass / http://127.0.0.1:9000/
  ProxyPassReverse / http://127.0.0.1:9000/
  LogLevel debug
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

并且不要忘记将" " 添加到您的/private/etc/hosts文件中:

127.0.0.1 myproject.loc
Run Code Online (Sandbox Code Playgroud)

毕竟,重新启动(或至少重新加载)Apache并刷新DNS缓存:

dscacheutil -flushcache
Run Code Online (Sandbox Code Playgroud)

然后运行你的Play应用程序,它应该在http://myproject.loc地址提供.

如果您尝试打开它太快(在Play控制台运行之前),您可能会遇到503错误,在这种情况下打开http:// localhost:9000,清除浏览器的缓存然后您的新"域"应该正常工作.