node.js - 有没有办法在 Node 服务器的 httpd conf 中设置 ProxyPass

标签 node.js apache vue.js httpd.conf mod-proxy

我运行 Apache httpd 服务器,该服务器在端口 80 上提供 Web 服务。同时,与 Vue js 配合使用的 Node.js 服务器在端口 8080 上运行。

为了进行多端口管理,我在 httpd conf 中提到了代理传递,如下所示。

LoadModule proxy_module /usr/lib64/apache2/mod_proxy.so
LoadModule proxy_http_module /usr/lib64/apache2/mod_proxy_http.so
<VirtualHost *:80>
        ProxyPass /node http://localhost:8080/node/
        ProxyPassReverse /node http://localhost:8080/node/
</VirtualHost>

下面显示的是设置上述代理设置后的错误。 提到的 app.js 可用作 http://localhost:8080/app.js

enter image description here

最佳答案

You can also solve this problem with CORS settings in Apache conf:

  # remember to replace /var/www with your directory root
  <Directory /var/www>
    # some other apache code here, if any
    # replace the url to the one you wanted
    Header set Access-Control-Allow-Origin "http://localhost:8080"
    # some other apache code here, if any
  </Directory>

关于node.js - 有没有办法在 Node 服务器的 httpd conf 中设置 ProxyPass,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60175109/

相关文章:

javascript - Ruby 非阻塞库与 Node

node.js - 在 Nodejs 中将回调转换为 RX.Observable

apache - 编辑多个 .htaccess 文件

vue.js - 如何将数据从 vuex 状态获取到本地数据进行操作

javascript - VueJS 与 FullCalendar : load fullCalendar ONLY after linking scripts in index. html

javascript - 新鲜的 vue cli 项目上出现奇怪的 CORS 错误

node.js - Nodejs运行由Golang错误生成的WASM但浏览器成功

ios - Socket.io 通过套接字对象在服务器上获取事件字符串

apache - Gzip 压缩不适用于 HTTPS

spring - 这很可能会在 Tomcat 中造成内存泄漏吗?