0

I have a server with Hetzner, and a few domains with Google Domains. I have an Apache server running on port 80, and a Node server running on port 8080.

If my server's IP is 192.0.2.4 and my domain example.com, I want to setup Google Domains so that:

So far I added these rules in Google Domain:

@    A        1h    192.0.2.4
www  CNAME    1h    example.com
a    CNAME    1h    ghs.googlehosted.com (added as a subdomain redirection from a.example.com to 192.0.2.4:8080)

And I have this behaviour:

What do I need to change to get it working? Do I need to do something on Hetzner side?

Patrick Mevzek
  • 9,273
  • 7
  • 29
  • 42
Tim Autin
  • 213
  • 2
  • 8

1 Answers1

0

The problem is that you redirect http://a.example.com to http://192.0.2.4:8080. A browser redirect causes the address bar in your web browser to change.

What you probably want is:

  1. Point a.example.com to the ip-address of your apache webserver via a DNS A record.
  2. Set up an extra name based virtual host in Apache for a.example.com
  3. Configure the a.example.com VirtualHost as a reverse proxy to your node server on port 8080.

You probably want a few additional directives but rougly you need something along the lines of:

<VirtualHost *:80>
  ServerName www.example.com
  ServerAlias example.com
  DocumentRoot /var/www/html/
</VirtualHost>
<VirtualHost *:80>
  ServerName a.example.com
  ProxyPass / http://localhost:8080/
  ProxyPassReverse / http://localhost:8080/
</VirtualHost>
Patrick Mevzek
  • 9,273
  • 7
  • 29
  • 42
HBruijn
  • 72,524
  • 21
  • 127
  • 192
  • Thanks, I didn't thought about virtual hosts! Your solution is working perfectly. And http://example.com no longer leads to a 404, I guess I just needed to wait. – Tim Autin Jul 02 '18 at 15:58