Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I figured out a way to solve this with Apache and mod_proxy. This allows both your Grails install and Grails project to remain pristine. No hacking at the Grails internals, no adding plug-ins you may not need in production.</p> <p><strong>1. Install Apache httpd 2.2</strong></p> <p>Do this however makes the most sense for your operating system. It is important that you install Apache 2.2. I did this on an Ubuntu system, so any specific commands and file locations will be for Ubuntu. Modify as necessary for your system.</p> <p>After you've installed Apache, start httpd.</p> <pre><code>sudo /sbin/service httpd start </code></pre> <p>Test that it is installed correctly using a web browser.</p> <p><strong>2. Create a root directory</strong></p> <p>Pick a location on your disk where you will keep your static files. This will be the document root for httpd. I will be using /var/grails_root.</p> <pre><code>mkdir /var/grails_root touch /var/grails_root/crossdomain.xml </code></pre> <p><strong>3. Create a VirtualHost in httpd.conf</strong></p> <p>Open httpd.conf in your favorite text editor.</p> <pre><code>vim /etc/httpd/conf/httpd.conf </code></pre> <p>Pick your favorite port, and create a virtual host on that port. I will be using 9090, but any port will do.</p> <p>Add these lines to httpd.conf</p> <pre><code>Listen 9090 &lt;VirtualHost *:9090&gt; DocumentRoot "/var/grails_root" &lt;Directory "/var/grails_root"&gt; Allow from all &lt;/Directory&gt; &lt;/VirtualHost&gt; </code></pre> <p>Restart httpd</p> <pre><code>sudo /sbin/service httpd restart </code></pre> <p>Test that you are now able to access the static files in your document root directory. If not, you will need to fix this before moving on to the next step.</p> <p><strong>4. Enable mod_proxy and mod_proxy_http</strong></p> <p>You need to load both of these modules. mod_proxy has the base functionality for proxying, and the mod_proxy_xxx modules have information specific to a protocol. They ship standard with httpd 2.2, so you shouldn't need to install anything extra.</p> <p>Add these lines to httpd.conf</p> <pre><code>LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so </code></pre> <p>Now modify the virtual host you set up in the previous step. (You can omit the comments)</p> <pre><code>&lt;VirtualHost *:9090&gt; DocumentRoot "/var/grails_root" &lt;Directory "/var/grails_root"&gt; Allow from all &lt;/Directory&gt; # New lines start here ProxyRequests Off &lt;Proxy *&gt; Order deny,allow Allow from all &lt;/Proxy&gt; ProxyPass /grailsApp http://your.grails.server:8080/grailsApp # New lines end here &lt;/VirtualHost&gt; </code></pre> <p>Restart httpd</p> <pre><code>sudo /sbin/service httpd restart </code></pre> <p>Now, you should be able to access both your static files and your Grails app via port 9090.</p> <p>This is all based on information found here: <a href="http://docs.codehaus.org/display/JETTY/Configuring+mod_proxy" rel="nofollow">http://docs.codehaus.org/display/JETTY/Configuring+mod_proxy</a></p> <p>Information for doing this with other versions of Apache is available on the same site.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload