-2

Basically, I have a Nodejs program running on port 4000 of my server and instead of the visitors having to type mydomain.com:4000 to access it, I'd like it to be displayed when they visit the normal domain of mydomain.com but I can't seem to get it to work.

This is what I've done when setting up the Virtual host in /etc/apache2/sites-available/:

<VirtualHost *:80>
    ServerName my-domain.net
    ServerAlias www.my-domain.net

    DocumentRoot /var/www/my-domain/public

    <Directory /var/www/myproject/public>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/myproject-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/myproject-access.log combined


    ProxyRequests Off
    Order deny,allow
    Allow from all

    ProxyPass / http://localhost:4000
    ProxyPassReverse / http://localhost:4000

</VirtualHost>

I then restarted the apache server and got this message: (note: “xxx.xxx.xxx.xxx” represents the IP of my VPS, e.g.15.26.32.9)

service apache2 restart
AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/conf.d/xxx.xxx.xxx.xxx.conf:1

All that is contained in that file is:

NameVirtualHost xxx.xxx.xxx.xxx:8080
Listen xxx.xxx.xxx.xxx:8080
NameVirtualHost xxx.xxx.xxx.xxx:8433
Listen xxx.xxx.xxx.xxx:8433

When I try access my site (with the nodejs program running with Forever) I keep getting a 403 Forbidden message. What would be the cause?

Any help is appreciated!

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
my90558
  • 1
  • 2

1 Answers1

0

[SOLUTION]

I have since found a solution that fixes my problem.

For anyone else with the same problem, do this. Simply redirect your port 80 to whatever other port you want to use with this command:

sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 4000 Source to answer:

https://stackoverflow.com/questions/16573668/best-practices-when-running-node-js-with-port-80-ubuntu-linode

my90558
  • 1
  • 2