apache代理服务器为nodejs服务设置域名

1.肯定是先配hosts,例如我本机配了www.test.com

2.在conf\extra\httpd-vhosts.conf中配置:

<VirtualHost *:80>

ServerAdmin webmaster@dummy-host2.localhost

ServerName www.test.com

ProxyRequests off

<Proxy *>

Order deny,allow

Allow from all

</Proxy>

ProxyPass / http://127.0.0.1:1337/

ProxyPassReverse / http://127.0.0.1:1337/

</VirtualHost>

3.用到了vhosts.conf嘛,所以在\conf\httpd.conf中将conf/extra/httpd-vhosts.conf给include上,又因为用到proxy,所以在\conf\httpd.conf中还要将proxy相关模块加上(默认是注释掉的),例如proxy_module modules/mod_proxy.so。

然后就可以通过www.test.com访问nodejs在1337接口创建的服务啦。