how to put nodejs and apache in the same port 80

前端 未结 6 1180
执笔经年
执笔经年 2020-12-04 17:04

I have to put nodejs in port 80, but apache is already using it. How can I put both (nodejs and apache) on the same port 80? I need it because in my university all the ports

6条回答
  •  死守一世寂寞
    2020-12-04 17:19

    You can also use Apache 2's mod_proxy and mod_proxy_http, which might be more reliable or perform better depending on your system.

    Here's an example:

    # Use Apache for requests to http://example.com/
    # but use Node.js for requests to http://example.com/node/
    
        ServerName example.com
        DocumentRoot /var/www/example/
        
            ProxyPass http://127.0.0.1:8124/
            ProxyPassReverse http://127.0.0.1:8124/
        
    
    

    And of course you can modify the directives to your needs, such as using a different port for your virtual host (e.g., 443), different port for Node.js, or set up the proxy under a different block, such as for a subdomain (e.g., node.example.com).

提交回复
热议问题