Skip to content
Eldelshell edited this page May 7, 2020 · 3 revisions

Even though Amforeas provides an easy way to publish a web-app, you might want to only use its webservices and provide access to your application by an HTTP server. This setup will be very important for your AJAX applications to be able to communicate with Amforeas.

Setting up

We are going to assume that you're running Amforeas and your HTTP server in the same machine, although this is not mandatory as you will see later.

  1. Set the amforeas.server.port and the amforeas.server.host environment variables to whatever fits you (i.e. localhost, 8080)
  2. Set up your database configuration
  3. Start Amforeas

Try doing a request directly to test everything is working fine:

curl "http://server:8080/amforeas/stats"

Setting up Apache

Enable the modules for Apache mod_proxy and mod_proxy_http

$ a2enmod mod_proxy
$ a2enmod mod_proxy_http

We will create a new virtual host for our application called demo so we can access it with the url http://www.server.com/demo/ with the following configuration:

<VirtualHost *:80>
  ServerName www.server.com
  RewriteEngine on
  RedirectMatch ^/$ /demo/

  ProxyPass /amforeas/ http://localhost:8080/amforeas/
  ProxyPassReverse /amforeas/ http://localhost:8080/amforeas/

  DocumentRoot /srv/www/htdocs/docroot
  CustomLog  /var/log/apache2/access_reports combined
  ErrorLog  /var/log/apache2/error_reports
</VirtualHost>

This should give you a quick start. The magic here is to allow AJAX requests to be made against the relative path /amforeas/foo to our web server, and it will proxy this requests to Amforeas. This way we don't have to worry about breaking our AJAX calls or using JSONP.