taspai
taspai

Reputation: 130

How to correctly set reverse proxy with apache2 for my meteor app

I have a meteor application I deployed using this method Deploy a meteor app which works fine and which now runs on mydomain.com:3000 but I want to have access to it on mydomain.com/myapp. For that I try to use apache2 with mods, following what I have read on the web my configuration is :

<VirtualHost *:80>
    ServerName mydomain.com

    Alias /myapp /home/me/Documents/myapp/bundle/public
    <Location /memo>
            PassengerBaseURI /myapp
            PassengerAppRoot home/me/Documents/myapp/bundle

            PassengerAppType node
            PassengerStartupFile main.js

    </Location>


    <Directory /home/me/Documents/myapp/bundle/public>
            Allow from all
            Options -MultiViews
    </Directory>


    ProxyPass /myapp http://localhost:3000/
    ProxyPassReverse /myapp http://localhost:3000/
</VirtualHost>

but when I go on mydomain.com/myapp I have a blank page while on mydomain.com:3000 this is working fine.

What's bad ?

EDIT: I'm wondering if the problem doesn't come from the meteor application because I have the title of the window at the top of my page (from my ) but the rest of the page is always empty.

So the redirection is working a little bit..

Could it be possible that my meteor app have difficulties to find his ressources because of the mydomain/myapp sub-uri and a mistake in the app configuration ? I have defined the ROOT_URL environment variable to mydomain.com/myapp

Upvotes: 0

Views: 596

Answers (2)

Mikkel
Mikkel

Reputation: 7777

Here is a setup I use to redirect /blog to a Meteor server (I don't use Passenger with Apache)

<VirtualHost *:80>
    ServerName myserver.com:80
    Redirect permanent / /blog/

    ProxyRequests Off
    ProxyVia Block
    ProxyPreserveHost On
    <Proxy *>
         Require all granted
    </Proxy>
# Meteor ghost blog
    ProxyPass /meteor/ http://172.31.1.11:3000/
    ProxyPassReverse /meteor/ http://172.31.1.11:3000/
</VirtualHost>

This works, but I must agree with @kalid-rafik that nginx is a much easier solution. Maybe you could ask for another ip address to use with nginx?

Upvotes: 0

Khalid Rafik
Khalid Rafik

Reputation: 49

for me apache2 is not a good choice to do this, you should use nginx instead

example of configuration:

server {
    listen 80;

    server_name example.com www.example.com;

    location /myapp {
        proxy_pass http://localhost:3000/;
    }
}

Upvotes: 2

Related Questions