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
1 Answer 1
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– smcs2017年08月18日 08:12:59 +00:00Commented 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.TheDiveO– TheDiveO2017年08月18日 08:29:36 +00:00Commented Aug 18, 2017 at 8:29
-
No luck though. The app is listening on port 80 now, and in
/etc/dnsmasq.conf
I addeddomain=test.me
and in/etc/hosts
I added192.168.1.1 go.test.me
. But I can't address the server by enteringgo.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– smcs2017年08月18日 13:01:22 +00:00Commented Aug 18, 2017 at 13:01 -
.me
is a TLD, can you check with.test
?TheDiveO– TheDiveO2017年08月18日 13:06:53 +00:00Commented 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'tsmcs– smcs2017年08月18日 13:10:13 +00:00Commented Aug 18, 2017 at 13:10