简体   繁体   English

Apache mod_proxy和Node Express呈现纯文本

[英]Apache mod_proxy and Node Express renders plain text

I am running a webserver with Apache 2.2.12 as default webserver bound to port 80. For a new project I need to proxy one of Apaches bound domains via port 80 to a Node Express Server 4.7 which runs on the same machine on port 4000. 我正在运行将Apache 2.2.12作为绑定到端口80的默认Web服务器的Web服务器。对于一个新项目,我需要通过端口80将Apache绑定的域之一代理到Node Express Server 4.7,该节点在端口4000上的同一台计算机上运行。

The Express process served alone is running fine with expected results. 单独提供的Express流程运行良好,并取得了预期的结果。 Means, when I visit my-domain.com:4000 everything looks good. 就是说,当我访问my-domain.com:4000时,一切看起来都很好。

Ok, so I set up a virtual host in Apache which should proxy my-domain.com to the Express server on port 4000. 好的,所以我在Apache中设置了一个虚拟主机,该主机应将my-domain.com代理到端口4000上的Express服务器。

I have tried proxying to localhost:4000 or my-domain.com:4000 but Apache is always rendering the Express response as plain text not as real HTML. 我尝试代理到localhost:4000或my-domain.com:4000,但是Apache始终将Express响应呈现为纯文本,而不是真实的HTML。 This means I see the HTML-String inside my browser instead of the parsed website. 这意味着我在浏览器中看到的是HTML-String,而不是解析后的网站。 The Browser just echos the Express string inside its own html-wrapper nested in a pre-tag when you explore the source code via inspector. 当您通过检查器浏览源代码时,浏览器只是在嵌套在预标签中的自己的html-wrapper中回显Express字符串。

My Apache-Config looks like this: 我的Apache-Config看起来像这样:

    <VirtualHost *:80>
       ServerName my-domain.com
       ProxyRequests Off
       <Proxy *>
         Order deny,allow
         Allow from all
       </Proxy>

      ProxyPass / http://localhost:4000/ 
      ProxyPassReverse / http://locahost:4000/
    </VirtualHost>

Any help or suggestions would be appreciated. 任何帮助或建议,将不胜感激。 Thx. 谢谢。

Found the parameter inside apache2.conf 在apache2.conf中找到参数

setting: 设置:

    DefaultType text/plain

to

    DefaultType text/html

worked out. 解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 一个网址中的Mod_proxy,apache和node.js - Mod_proxy , apache and node.js in one url Ajax使用apache mod_proxy并从其他域调用nodejs时的会话 - session when ajax call to nodejs with apache mod_proxy and from a different domain Express-handlebars 呈现纯文本而不是 HTML - Express-handlebars renders plain text instead of HTML Mod_proxy服务器流,用于通过托管的JavaScript应用发出HTTP请求 - Mod_proxy server flow for making HTTP requests via a hosted javascript app Apache + Node.js + mod_proxy。 转发到https和应用程序无法正常工作 - Apache + Node.js + mod_proxy. Getting forwarded to https and app is not working Apache + Node.js + mod_proxy。 如何将一个域路由到:3000,将另一个域路由到:80 - Apache + Node.js + mod_proxy. How to route one domain to :3000 and another to :80 在express.node.js中链接玉器渲染 - Chaining jade renders, in node.js with express apache和节点表示,带有节点重写 - apache and node express with node rewrites node.js express-MIME类型woff字体作为文本/纯文本类型返回 - node.js express - mime type woff font returned as text/plain type 在apache2服务器上的快速节点js中提供静态文件时,自动重定向而不使用代理传递名称 - Automatically redirected without proxy pass name while serving static files in express node js on apache2 server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM