- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我尝试在现有的 apache 旁边运行 Node.js,但在从 Express.js 服务器提供内容时遇到 ProxyPass 问题。问题似乎在于 Node 服务器在 Apache 转发时看到的请求。
我尝试了这个配置:
<VirtualHost *:80>
DocumentRoot "/var/www/html"
ProxyPreserveHost on
ProxyPass /node http://localhost:3000/
ProxyPassReverse /node http://localhost:3000/
</VirtualHost>
Node 设置服务器如下:
var express = require('express')
, app = express()
, server = require('http').createServer(app)
, io = require("socket.io").listen(server)
app.use(function(req, res, next){
console.log(req.method, req.url); // log the method and route
next();
});
app.use(express.static(__dirname + '/public'));
app.use('/components', express.static(__dirname + '/components'));
app.use('/js', express.static(__dirname + '/js'));
我得到了 Node 的记录:
GET /
GET //components/bootstrap/dist/css/bootstrap.css
GET //components/font-awesome/css/font-awesome.css
GET //css/flags.css
GET //css/app.css
GET //components/jquery/dist/jquery.js
GET //components/bootstrap/dist/js/bootstrap.js
GET //socket.io/socket.io.js
GET //js/client.js
GET //components/bootstrap/dist/css/bootstrap.css.map
问题:当 apache 发送请求并且不提供 socket.io 库时,我收到了额外的斜杠。如何让 Apache 在到达 Node.js 之前删除前导斜杠?
最佳答案
我最终选择使用 HAProxy 来取代 Node 和 apache;正如上面评论中所建议的。
这些是我使用的设置:
frontend main
bind *:80
mode http
default_backend apache
acl is_node path_beg -i /node/
use_backend node if is_node
acl is_node_too path_beg -i /node
use_backend node if is_node_too
acl is_socket path_beg -i /socket.io/
use_backend socketio if is_socket
acl is_socketio_too path_beg -i /socket.io
use_backend socketio if is_socketio_too
backend apache
mode http
balance roundrobin
server apache localhost:81
backend node
mode http
balance roundrobin
server node localhost:3000
reqrep ^([^\ :]*)\ /node/(.*) \1\ /\2
reqrep ^([^\ :]*)\ /node(.*) \1\ /\2
backend socketio
mode http
balance roundrobin
server node localhost:3000
reqrep ^([^\ :]*)\ /node/(.*) \1\ /\2
reqrep ^([^\ :]*)\ /node(.*) \1\ /\2
关于node.js - Apache ProxyPass 和 Node.js - 不提供 socket.io,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33425499/
我在设置 Proxypass 时遇到了两个问题。我已经在我的 Apache 设置中设置了 Proxypass。 例如: ProxyPass / http://www.domainname.com:80
我在给定的机器上运行了多个网络服务器(Apache、Tomcat、自定义 Python 服务器)。我让 Apache 监听端口 80,这是标准设置。为了通过此端口访问我的其他服务器之一,我在 Apac
我尝试设置 nginx,使其将请求代理到多个位置。例如。 /location1和 /location2都应该代理到 http://localhost:8080 .我只是不知道如何在不使用多个位置块的情
我有以下 nginx.conf location /monitoring/prometheus/ { resolver 172.20.0.10 valid=5s; set $prometheu
这就是我需要实现的目标我需要将所有对/public/的请求代理到另一台服务器,但对/public/forms/的请求不得被代理,而应由该 apache 服务器提供服务。 我已将这些指令添加到我的 ht
我正在尝试在我们的标准 http 代理服务器上为我的公司环境的 ActiveMQ 管理页面设置代理。我有一个规则,允许我访问管理登录页面: ProxyPass /foobar hostname:816
我最近将我们的一个网站迁移到了 Apache 2.0 和 Tomcat7 AWS,但我的 ProxyPass 指令有问题 ProxyPass / http://10.1.1.1:8080/faith/
我必须将 80 上的所有 apache 请求重定向到 8080 上的 tomcat,一条路径除外。 所以,如果接收到 http://example.com/anything --> tomcat:80
我正在使用 apache 作为反向代理,我可以对除某些 URL 之外的所有 URL 执行 ProxyPassReverse 吗?例如这是我的配置: ProxyPass /myapp http://lo
所以我使用 Apache 将特定文件夹代理到 Glassfish 实例。我的conf中的规则是: ProxyPass /folder http://localhost:28083 ProxyPassR
如果我有两个代理规则并且它们“重叠”,有没有办法指定最重要的规则? 示例(虚拟主机定义的一部分) ProxyPass /foo http://bar:8180/ ProxyPass / http://
我尝试排除所有以 "dgg-" 开头并以 ".xml" 结尾的文件,例如:dgg-file-1。 xml 使用 apache 代理。 这有效: ProxyPass /myfile.xml ! # si
我尝试了这个问题的答案。 How to merge multiple ProxyPass directives in Apache? 但是当我启动 apache 时出现错误,提示 ProxyPass|
由于 horrible, horrible errors ,我们更改了 Apache 连接到 Tomcat 的方式。我们正在使用 mod_jk : JkMount /path ajp13 现在我们使用
我在使用 mod_proxy 和 proxypass 指令时出现以下错误: 我的虚拟主机文件: LoadModule proxy_module modules/mod_proxy.so
我知道如何使用 ProxyPass 设置 apache 服务器。以便客户端可以连接到特定的 url,被重定向到另一个 url,但无法识别这一点,因为他输入的 url 仍然存在。 我必须使用 apach
我正在使用以下 Apache 配置将请求转发到 Tomcat 服务器: ProxyPass /myapp ajp://localhost:8009/myapp max=2 这是一个简化的配置,但足以重
我试图通过在 web.xml 文件中使用过滤器来锁定对我的 Tomcat WebApp 的管理部分的访问。 Remote Address Filter
我在同一台机器上使用 Apache 和 Tomcat 服务器时遇到了一些问题。我想将虚拟主机 kb.domain 重定向到 tomcat 应用程序 kb。 我已经阅读了互联网上的一些帖子,但没有找到解
这个让我抓狂。我有一个活跃且正在使用的 Apache 代理服务器在 EC2 上提供内容。它运行良好,并且具有各种配置如下的虚拟主机: ServerName m.FOO.com Ser
我是一名优秀的程序员,十分优秀!