meteor app with apache as proxy is (probably) redirecting all pages

蓝咒 提交于 2019-12-12 02:14:05

问题


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


回答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




回答2:


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;
  }
}


来源:https://stackoverflow.com/questions/31474072/meteor-app-with-apache-as-proxy-is-probably-redirecting-all-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!