首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在端口80上使用Apache运行Node.js网站

在端口80上使用Apache运行Node.js网站
EN

Stack Overflow用户
提问于 2019-06-05 02:06:13
回答 1查看 0关注 0票数 0

我有一个CentOS 6 VPS与Apache使用端口80来托管我的一些网站。但是,我的一个网站现在要求Node.js用于其中一个功能,但是运行Node脚本证明相当困难,因为我希望它在端口80上运行,但apache2目前正在使用它。这是根据下面的错误。

错误:听EADDRINUSE:地址已在使用0.0.0.0:80

我的网站域名是new.johnsykesfoundation.org。它不是我的cPanel的默认域,并嵌套在public_html / xxxxxx中。我在我的httpd.conf文件中实现了以下内容,但仍然无法正常工作。我必须遗漏一些东西。

代码语言:javascript
复制
<VirtualHost *:80>
    ServerName new.johnsykesfoundation.org
    ProxyPreserveHost on
    ProxyPass /home/jscuizj1n8m0/public_html/newjsf

    <Location "/charge">
            ProxyPreserveHost On
            ProxyPass http://localhost:3000/charge
            ProxyPassReverse http://localhost:3000/charge
    </Location>

</VirtualHost>

mod_proxy 也启用了。

EN

回答 1

Stack Overflow用户

发布于 2019-06-05 11:40:12

一个起点是添加一个位置条目来使用proxypass指令:

代码语言:javascript
复制
<Location "/external/url/to/node/service/">
    ProxyPreserveHost On
    ProxyPass  http://localhost:10000/internal/url/
    ProxyPassReverse  http://localhost:10000/internal/url/
</Location>


#/external/url/to/node/serivce/   
# This is the url connecting clients will access through apache.
# It ca be what ever you like. So for example people will access:
# http://www.yourdomain.org/mynodeservice
# in a browser this will actually access the node service

#ProxyPass http://localhost:10000/
#                     ^        ^
#                   host       port
#                    running     node
#                      node       is listening on
#
# This sets up the proxy to forward the request above to this host and location.

我在此示例中使用了端口10000,但您需要选择一个适合您的设置。注意结束斜杠在LocationProxyPass指令中很重要。结帐https://httpd.apache.org/docs/trunk/mod/mod_proxy.html#proxypass

UPDATE

也许这有效:

代码语言:javascript
复制
<VirtualHost *:80>
    ServerName new.johnsykesfoundation.org
    ProxyPreserveHost on
    ProxyPass /home/jscuizj1n8m0/public_html/newjsf

    <Location "http://new.johnsykesfoundation.org/charge">
        ProxyPreserveHost On
        AllowMethods POST GET
        Require all granted
        ProxyPass http://localhost:3000/charge
        ProxyPassReverse http://localhost:3000/charge
    </Location>
</VirtualHost>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100006926

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档