问题描述
我运行生产应用程序的流星,流星使用UP部署,我使用Apache作为代理。
I run a meteor app on production, using Meteor UP to deploy, I use apache as a proxy.
当我直接浏览到一个页面(www.example.net/any-page)生产,我被重定向(到www.example.net)
When I surf directly to a page (www.example.net/any-page) on production, i'm being redirected (to www.example.net)
以下从这个答案(感谢意见后, ),我现在有这个Apache的配置:
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>
所有流量example.net被重定向到www.example.net。完善。
但是,所有的流量(WWW)example.net/any-page-or-folder也被重定向到www.example.net。不是那么完美。我不明白这有什么错我的配置,我想我正确地实现了答案其他计算器问题。
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 .
这个问题其实从这个problem
推荐答案
唉。不要使用Apache的代理,这是矫枉过正。 nginx的安装,使用MUP部署流星的应用程序(以3000端口为例),然后在下面添加config来 /etc/nginx/sites-enabled/myapp.conf
:
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;
}
}
这篇关于在Apache代理是(可能)流星应用重定向所有页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!