我运行 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
最佳答案
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/