0

I would like to run a meteor.js app in a subfolder (/home/www/public/v1) of a domain (/home/www/public) served by an Apache (2.4.7) server. I have set up a virtualhost which listens to port 80, and proxies locations starting with "v1" to the nodejs app. It works fine (I think) except that I get a 404 page generated by meteor.js.

Must I modify the meteor.js setup to accept requests coming from "domain.tld/v1" instead of "domain.tld" ? If so, which file(s)? Is this sort of setup possible at all?

The virtualhost configuration (edited for legibility)

<VirtualHost *:80>
    ServerName domain.tld
    DocumentRoot /home/username/www/domain.tld/public

    <Directory />
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    <Directory /home/username/www/domain.tld/public/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from All
        Require all granted
    </Directory>

        # NODEJS APP in V1 FOLDER
        ProxyRequests on
    <Proxy *>
        Order deny,allow
        Allow from all
        Require all granted
    </Proxy>
    <Location "/v1/">
        ProxyPreserveHost on
        ProxyPass http://localhost:3000/
        ProxyPassReverse http://localhost:3000/
    </Location>
 </VirtualHost>
pixeline
  • 658
  • 3
  • 12
  • 29

1 Answers1

2

Configuration

You configuration is correct but some options are outdated and other not needed:

<VirtualHost *:80>
    ServerName domain.tld
    DocumentRoot /home/username/www/domain.tld/public

    <Directory />
        Options +FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /home/username/www/domain.tld/public/>
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
    </Directory>

    # NODEJS APP in V1 FOLDER
    <Location "/v1">
        ProxyPass http://localhost:3000/V1
        ProxyPassReverse http://localhost:3000/V1
    </Location>
 </VirtualHost>

Meteor.js will be redirected from port 3000/v1 to port 80/v1

More info:

This no more exist in Apache 2.4

Order allow,deny
allow from All

This is needed when you got restriction

Require all granted

This will make your server to proxy any request, and it is not required for what you need (https://httpd.apache.org/docs/2.4/en/mod/mod_proxy.html#proxyrequests)

ProxyRequests on

This is optional in your case (https://httpd.apache.org/docs/2.4/en/mod/mod_proxy.html#proxypreservehost)

ProxyPreserveHost on
Froggiz
  • 3,013
  • 1
  • 18
  • 30
  • Thank you for the heads up. Do I have to modify the meteor.js application setup ? It sits in a "v1" folder. – pixeline Nov 26 '15 at 14:47
  • i changed `/v1/` to `/v1` to prevent 404 error when you do `domain.tld/v1` without trailing slash. But to fully works, link need to be subtitute else files will miss `/v1` in their path – Froggiz Nov 26 '15 at 16:30
  • I didn't found how to redirect the proxy content, but this is a trick : if proxy path is the same as proxied path all will works, so put your test project in http://localhost:3000/v1 (i edited my post) – Froggiz Nov 26 '15 at 17:10