How to setup reverse proxy in apache for play framework web app on mac os x

10,274

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.

Share:
10,274
Admin
Author by

Admin

Updated on June 23, 2022

Comments

  • Admin
    Admin almost 2 years

    I'm trying to add an apache front end with reverse proxy to a play framework app on port 9000. I've tried the following httpd configuration as per the play documentation: 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>
    

    I have loaded only the mod_proxy module, but have commented out all other proxy related modules (http, ajp, jk, etc).

    When I try to hit http://localhost, I get the following in the error log:

    [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)
    

    When I use apachectl to see what modules have been loaded, I'm seeing this:

    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
    

    So both proxy_http and proxy_ajp are getting loaded even though I commented them out. I'm trying to use the apache (2.2.21) that came on my mac running osx lion. Any ideas on what is wrong here?