使用apache作为代理的meteor应用程序(可能)正在重定向所有页面
我在生产环境中运行meteor应用程序,使用meteor UP进行部署,使用apache作为代理 当我直接浏览到生产上的一个页面(www.example.net/任何页面)时,我被重定向到了(www.example.net) 根据本文的答案(thx至注释),我目前拥有以下apache配置:使用apache作为代理的meteor应用程序(可能)正在重定向所有页面,apache,redirect,meteor,virtualhost,http-proxy,Apache,Redirect,Meteor,Virtualhost,Http Proxy,我在生产环境中运行meteor应用程序,使用meteor UP进行部署,使用apache作为代理 当我直接浏览到生产上的一个页面(www.example.net/任何页面)时,我被重定向到了(www.example.net) 根据本文的答案(thx至注释),我目前拥有以下apache配置: <VirtualHost *:80> ServerName example.net Redirect permanent / http://www.example.
<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>
ServerName示例.net
重定向永久/http://www.example.net/
服务器名www.example.net
ServerAlias示例.net
代理请求关闭
重新启动发动机
命令拒绝,允许
通融
ProxyPasshttp://localhost:8081/
ProxyPassReversehttp://localhost:8081/
所有到example.net的流量都被重定向到www.example.net。完美的
但是(www.)example.net/any-page-or-folder的所有流量也被重定向到www.example.net。不太完美。我不明白我的配置出了什么问题,我想我正确地实现了另一个stackoverflow问题的答案
这个问题实际上来源于这个我通常使用nginx来解决这个问题,我也鼓励您这样做,但在我看来,这是您第一次重定向。您的第一个重定向是将www.example.com上的任何页面重定向到example.com 基本上,无论发生什么事情,所有内容都会进入主页
看看这篇文章的答案,看看你想做什么 啊。不要将Apache用作代理,这太过分了。安装nginx,使用mup部署Meteor应用程序(例如端口3000),然后将下面的配置添加到
/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。。是这样的:感谢您的建议,我稍后将把配置移到nginx:)