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

asked Aug 17, 2017 at 13:55

1 Answer 1

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).

answered Aug 17, 2017 at 19:48
8
  • 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. Commented Aug 18, 2017 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. Commented Aug 18, 2017 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..? Commented Aug 18, 2017 at 13:01
  • .me is a TLD, can you check with .test? Commented Aug 18, 2017 at 13:06
  • I just tried go.bla.test. Same behaviour, it works when not connected to the internet, otherwise it doesn't Commented Aug 18, 2017 at 13:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.