Deploying play! 2.0 application on an apache server with a reverse proxy

Posted by locrizak on Server Fault See other posts from Server Fault or by locrizak
Published on 2012-05-05T15:17:54Z Indexed on 2013/07/01 17:09 UTC
Read the original article Hit count: 432

Filed under:
|
|
|

I'm trying to deploy my play! 2.0 application on an Ubuntu 11.10 server and I have been running into error after error and hope someone can help me here. I am try to deploy my Play! application using a reverse proxy on Apache 2. I have enabled the apache proxy modules and configured the proxy.conf file in mods_enabled. The vhost for my domain looks like this:

<Directory /var/www/stage.domain.com>
    AllowOverride None
    Order Deny,Allow
    Deny from all
</Directory>

<VirtualHost *:80>

    DocumentRoot /var/www/stage.domain.com/web

    ServerName stage.domain.com
    ServerAdmin [email protected]

#    ProxyRequests Off
#    ProxyPreserveHost On
     <Proxy *>
        Order allow,deny
            Allow from all
     </Proxy>
#    ProxyVia On
#    ProxyPass /play/ http://localhost:9000/
#    ProxyPassReverse /play/ http://localhost:9000/


    ErrorLog /var/log/ispconfig/httpd/stage.domain.com/error.log


    ErrorDocument 400 /error/400.html
    ErrorDocument 401 /error/401.html
    ErrorDocument 403 /error/403.html
    ErrorDocument 404 /error/404.html
    ErrorDocument 405 /error/405.html
    ErrorDocument 500 /error/500.html
    ErrorDocument 502 /error/502.html
    ErrorDocument 503 /error/503.html

    <IfModule mod_ssl.c>
    </IfModule>
    <Directory /var/www/stage.domain.com/web>
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    <Directory /var/www/clients/client2/web7/web>
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>



    # Clear PHP settings of this website
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler None
    </FilesMatch>
    # mod_php enabled
    AddType application/x-httpd-php .php .php3 .php4 .php5
    php_admin_value sendmail_path "/usr/sbin/sendmail -t -i [email protected]"
    php_admin_value upload_tmp_dir /var/www/clients/client2/web7/tmp
    php_admin_value session.save_path /var/www/clients/client2/web7/tmp
        # PHPIniDir /var/www/conf/web7
    php_admin_value open_basedir /var/www/clients/client2/web7/:/var/www/clients/client2/web7/web:/va$


    # add support for apache mpm_itk
    <IfModule mpm_itk_module>
      AssignUserId web7 client2
    </IfModule>

    <IfModule mod_dav_fs.c>
          # Do not execute PHP files in webdav directory
      <Directory /var/www/clients/client2/web7/webdav>
            <FilesMatch "\.ph(p3?|tml)$">
          SetHandler None
        </FilesMatch>
      </Directory>
      # DO NOT REMOVE THE COMMENTS!  
      # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
      # WEBDAV BEGIN
      # WEBDAV END
    </IfModule>
#       <Location /play/>
#               ProxyPass http://localhost:9000/
#               SetEnv force-proxy-request-1.0 1
#               SetEnv proxy-nokeepalive 1
#       </Location>   
        ProxyRequests Off
        ProxyPass /play/ http://localhost:9000/  
        ProxyPassReverse /play/ localhost:9000/
        ProxyPass /play http://localhost:9000/
ProxyPassReverse /play http://localhost:9000/

#       SetEnv force-proxy-request-1.0 1
#       SetEnv proxy-nokeepalive 1
</VirtualHost>

This vhost file was generated by ispconfig and I have not touched anything that was there before just added onto. As you can see by the commented out parts I have tried a lot of different things based on random tutorials I have found but all of them have ended up in Internal Server Error, 503 and most often a '502 Bad Gateway`.

I can start play and it does connect successfully to my database. I can get a page to show up when there is an error and the play! stack trace error pages comes up but where everything is fine I get one of the errors above.

My application.conf file looks like this:

db info
.......
application.mode=PROD
logger.root=ERROR

# Logger used by the framework:
logger.play=INFO

# Logger provided to your application:
logger.application=DEBUG

http.path="/play/"
XForwardedSupport="127.0.0.1"

And my hosts file looks like this (I have never changed or added anything to the host file):

127.0.0.1       localhost
127.0.1.1       matrix

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Any insights onto what I might be doing wrong or if theres anything I can try please let me know! Thanks!!

Edit

Again the reverse proxy will work (I checked with sending to to google.com). Its when there is a successful connection to Netty. It's like Netty refuses the connection to the page.

Edit 2

output from apachectl -S

_default_:8081         127.0.0.1 (/etc/apache2/sites-enabled/000-apps.vhost:10)
*:8090                 is a NameVirtualHost
         default server 127.0.0.1 (/etc/apache2/sites-enabled/000-ispconfig.vhost:10)
         port 8090 namevhost 127.0.0.1 (/etc/apache2/sites-enabled/000-ispconfig.vhost:10)
*:80                   is a NameVirtualHost
         default server 127.0.0.1 (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost 127.0.0.1 (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost domain.com (/etc/apache2/sites-enabled/100-domain.com.vhost:7)
         port 80 namevhost domain.com (/etc/apache2/sites-enabled/100-domain.com.vhost:7)
         port 80 namevhost domain.com (/etc/apache2/sites-enabled/100-domain.com.vhost:7)
         port 80 namevhost domain.com (/etc/apache2/sites-enabled/100-domain.com.vhost:7)
         port 80 namevhost domain.com (/etc/apache2/sites-enabled/100-domain.com.vhost:7)
         port 80 namevhost stage.domain.com (/etc/apache2/sites-enabled/100-stage.domain.com.vhost:7)
         port 80 namevhost domain.com (/etc/apache2/sites-enabled/100-domain.com.vhost:7)

© Server Fault or respective owner

Related posts about apache2

Related posts about ubuntu