I am trying to run node js
and apache
in a same server for that
I am trying to pipe all requests to a particular port (eg: example.com:80 to example.com:3000).
For that, I changed httpd.conf file located in “/etc/httpd/conf/httpd.conf
“
Added these lines st the end
<VirtualHost *:80>
ServerName mysite.com
ProxyPreserveHost on
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>
and restarted using sudo service httpd restart
but nothing changed.
There are more 2 httpd.conf files available ->
/usr/local/apache/conf/httpd.conf
/etc/httpd/conf/httpd.conf
/etc/apache2/conf/httpd.conf
at the end of /etc/apache2/conf/httpd.conf
file I saw this:
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# DO NOT EDIT. AUTOMATICALLY GENERATED. USE INCLUDE FILES IF YOU NEED TO MAKE A CHANGE
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
I cannot understand the line USE INCLUDE FILES IF YOU NEED TO MAKE A CHANGE
.
What should I do????
2
Answers
I haven’t used Apache2 in a while as I would usually use Nginx to proxy my Node.JS applications.
You should copy the default site config from
/etc/apache2/sites-available/000-default.conf
. (Command:sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mysite.com.conf
).Then place the configuration that you have there into the new file. Edit what needs editing then enable the new site configuration by running
sudo a2ensite mysite.com.conf
. Then restart the apache2 process by runningsudo service apache2 restart
.You should now be able to test it and it should work if your configuration syntax is correct.
I personally prefer Nginx over Apache2 but you can use any of them.
for apache2 you should enable
proxy
andproxy_http
modules:then you should add a config file for apache usually named
/etc/apache2/sites-available/example.com.conf
:(you can remove Directory part if you don’t need it)
then enable the config and restart apache2 with:
for Nginx config you should add these lines to
/etc/nginx/site-available/your-app.conf
:then you should run:
and then:
P.S: I used the apache conf example from this link