0

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)
2
  • Please can you provide the output from apachectl -S?
    – Alex Leach
    May 9, 2012 at 17:30
  • @AlexLeach updated in question
    – locrizak
    May 9, 2012 at 19:36

2 Answers 2

0

I've found the best way to proxy incoming connections is to do so using mod_rewrite. Can't guaratee anything, but something like what's below might work for you. Of course you'll need to enable mod_rewrite in the server settings.

<Location /play>
    Order deny,allow
    Allow from all
</Location>
RewriteEngine on
RewriteRule ^https?://%{SERVER_NAME}/play/?(.*)$ http://localhost:9100/$1 [P,L]

Another thing you'll need to make sure of, is that any virtual server listening on port 80 is a name-based virtual host. apachectl -S should tell you whether there's multiple hosts listening on port 80.

1
  • The problem isn't with the proxy (it works) its more with connecting to port 9000 either as localhost:9000 in lynx or stage.domain.com:9000 / stage.domain.com/play in the browser
    – locrizak
    May 9, 2012 at 19:45
0

Start with the basics in your vhost:

ProxyPreserveHost On
ProxyPass /play http://localhost:9000/play
ProxyPassReverse /play http://localhost:9000/play

And you can add other directives once you have this portion working.

At the very least, these lines should proxy the main page. I imagine, you can get to http://localhost:9000/play without issue? To troubleshoot further, enable logging for mod_proxy: http://httpd.apache.org/docs/current/logs.html#permodule

7
  • I've updated my question. I cannot get localhost:9000/play to work. It returns Bad Gateway in the browser and in lynx if I type localhost:9000 the connection is refused and is aborted.
    – locrizak
    May 9, 2012 at 19:43
  • 1
    if you can't connect to localhost:9000, then the Play server doesn't sound like it's listening, or accepting connections on that port. Check that port's actually being used, with sudo netstat -tulpn | grep 9000. For the proxy to work, I think you might need to provide application.conf with the IP address of the proxy server, as seen from the client. Quoting playframework.org/documentation/1.1/production: ""Play will change the request.remoteAddress from the proxy’s IP to the client’s IP. You have to list the IP addresses of your proxy servers for this to work.""
    – Alex Leach
    May 9, 2012 at 20:36
  • (Sorry, wrong sub-post)
    – Alex Leach
    May 9, 2012 at 20:55
  • That gives me this: tcp6 0 0 :::9000 :::* LISTEN 15847/java It looks like it is listening but it just get disconnected via jetty
    – locrizak
    May 10, 2012 at 0:51
  • 1
    That's an IPv6 port, and your Apache process is proxying the connection through to the IPv4 localhost port. In firefox, you should be able to access this with the address http://[::1]:9000, but that won't help your proxy issues. Either reconfigure the proxy to point to ::1, or update your play app to listen on IPv4.
    – Alex Leach
    May 11, 2012 at 11:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .