0

I run a meteor app on production, using Meteor UP to deploy, I use apache as a proxy.

When I surf directly to a page (www.example.net/any-page) on production, i'm being redirected (to www.example.net)

After following the answer from this question (thx to comments), I currently have this apache config:

<VirtualHost *:80>
        ServerName example.net
        Redirect permanent / http://www.example.net/
</VirtualHost>

<VirtualHost *:80>
        ServerName www.example.net
        ServerAlias example.net
        ProxyRequests off
        RewriteEngine on

        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>
        <Location />
                ProxyPass http://localhost:8081/
                ProxyPassReverse http://localhost:8081/
        </Location>
</VirtualHost>

All traffic to example.net is being redirected to www.example.net. Perfect. But all traffic to (www.)example.net/any-page-or-folder is also being redirected to www.example.net. Not so perfect. I don't understand what's wrong with my config and I think I correctly implemented the answer to the other stackoverflow question .

This question actually originates from this problem

Community
  • 1
  • 1
flowen
  • 536
  • 4
  • 23
  • What is the question here? Doesn't make much sense... – Michael Mason Jul 17 '15 at 13:30
  • please pardon me for incorrect use of terminology or english. I'll write a different question to target the actual problem – flowen Jul 19 '15 at 08:00
  • so I corrected the question and hopefully made it more clear after asking http://stackoverflow.com/questions/31499198/www-and-non-www-mismatch-security-issue-with-oauth-fb-tw-and-browser-policy-pack?noredirect=1#comment50962486_31499198 It seems I still need a correct answer to this problem – flowen Jul 19 '15 at 11:06
  • so after a few spins and runs I finally discovered it wasn't Apache at all.. it was this: http://stackoverflow.com/questions/31504487/iron-router-onbeforeactions-is-redirecting-to-startpage/31504736#31504736 – flowen Jul 19 '15 at 19:00

2 Answers2

1

I generally use nginx for this, and would encourage you to do so as well, but it looks to me that it's your first redirect that's doing this. What your first redirect is saying is to redirect any page at www.example.com to example.com.

Basically, everything goes to the home page no matter what.

Check out the answer on this post for what you're trying to do. https://stackoverflow.com/a/15057194/1327678

Community
  • 1
  • 1
thatgibbyguy
  • 4,033
  • 3
  • 23
  • 39
1

Ugh. Don't use Apache for a proxy, it's overkill. Install nginx, deploy your Meteor app using mup (to port 3000 for example), then add the config below to /etc/nginx/sites-enabled/myapp.conf:

server {
  listen                *:80;

  server_name           myapp.com;

  access_log            /var/log/nginx/myapp.access.log;
  error_log             /var/log/nginx/myapp.error.log;

  location / {
    proxy_pass http://127.0.0.1:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header X-Forwarded-For $remote_addr;
  }
}
CaptSaltyJack
  • 15,283
  • 17
  • 70
  • 99