1

I am using a Raspberry Pi 3 running Raspbian 1.3 as a WLAN access point. To achieve this, I followed this tutorial (German). Basically I gave it a static IP address of 192.168.1.1 and installed dnsmasq and hostapd. It is running a node.js app on port 3000 which I can access fine when connected to its WLAN network. Next I'd like to access the app by entering a domain name in the address bar of my browser, instead of 192.168.1.1:3000. How could this be achieved? I have tried modifying the following files:

In /etc/dnsmasq.conf added domain=mydomain.bla

In /etc/hosts added 192.168.1.1:3000 test.mydomain.bla

0

The /etc/hosts config file only lists host-to-IP address mappings, but never (service) ports. So, a :3000 doesn't belong here, simply remove it. You need to specify the port number explicitly in your URL anyway if it differs from port 80. Port numbers in URLs are a dedicated element and don't belong to the host DNS name/IP address part in an URL. They are dealt with within the browser, but not in DNS (DNS SVR RRs are not taken into account when resolving URLs).

  • Thank you for the answer and background info, it works now. Would there be any reason not to have the node.js app listen on port 80 so the port doesn't need to be specified in the URL? The sole purpose of the device is to run this app. – smcs Aug 18 '17 at 8:12
  • @speedymcs there's no reason against using port 80, unless you already have another webserver running there. But normally, port 80 should be unused. – TheDiveO Aug 18 '17 at 8:29
  • No luck though. The app is listening on port 80 now, and in /etc/dnsmasq.conf I added domain=test.me and in /etc/hosts I added 192.168.1.1 go.test.me. But I can't address the server by entering go.test.me in the address bar, only the IP address works. Edit: It works when I unplug the ethernet cable, so the browser is obviously searching an internet DNS server instead of the Pi. I guess I'll have to stick to the IP address..? – smcs Aug 18 '17 at 13:01
  • .me is a TLD, can you check with .test? – TheDiveO Aug 18 '17 at 13:06
  • I just tried go.bla.test. Same behaviour, it works when not connected to the internet, otherwise it doesn't – smcs Aug 18 '17 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.