Running Node.js in apache?

后端 未结 7 1096
予麋鹿
予麋鹿 2020-11-28 02:41

We have an Apache Webserver installed on a machine which also serves pages using Perl.

For a project I\'ve decided to use Node.js instead of Perl/Ruby. Just wonderin

7条回答
  •  悲哀的现实
    2020-11-28 02:59

    Hosting a nodejs site through apache can be organized with apache proxy module.

    It's better to start nodejs server on localhost with default port 1337

    Enable proxy with a command:

    sudo a2enmod proxy proxy_http
    

    Do not enable proxying with ProxyRequests until you have secured your server. Open proxy servers are dangerous both to your network and to the Internet at large. Setting ProxyRequests to Off does not disable use of the ProxyPass directive.

    Configure /etc/apche2/sites-availables with

    
        ServerAdmin admin@site.com
        ServerName site.com
        ServerAlias www.site.com 
    
        ProxyRequests off
    
        
            Order deny,allow
            Allow from all
        
    
        
            ProxyPass http://localhost:1337/
            ProxyPassReverse http://localhost:1337/
        
    
    

    and restart apache2 service.

提交回复
热议问题