3

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

<VirtualHost *:80>
  ProxyPreserveHost On
  ServerName http://localhost
  ProxyPass / http://127.0.0.1:9000/
  ProxyPassReverse / http://127.0.0.1:9000/
  LogLevel debug
</VirtualHost>

我只加载了 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)

当我使用 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

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

4

1 回答 1

6

Try to use other name than localhost, ie:

<VirtualHost *:80>
  ProxyPreserveHost On
  ServerName myproject.loc
  ProxyPass / http://127.0.0.1:9000/
  ProxyPassReverse / http://127.0.0.1:9000/
  LogLevel debug
</VirtualHost>

and don't forget to add the 'domain' into your /private/etc/hosts file:

127.0.0.1 myproject.loc

After all, restart (or at least reload) the Apache and flush DNS cache:

dscacheutil -flushcache

then run your Play app and it should be available at http://myproject.loc address.

If you'll try to open it too fast (before Play console will run it) you can meet 503 error, in such case open http:// localhost:9000, clear the browser's cache and then your new 'domain' should be working.

于 2012-08-24T17:59:17.023 回答