I would like to connect a client to my Node.js web server via my rpi access point.

I have successfully setup my rpi3 stretch as an access point. Now I am trying to have the client redirected to the simple web server running on the Pi.

I have seen this iptables redirection but its not working for me.

iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination localhost:80
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination localhost:80

Once my client connects to the RPi AP wifi I am not redirected to any browser to the destination of the server. I can verify the iptable rules are there using.

iptables -t nat -L -n -v

I would like to be able to have the client redirected to a browser and the destination with out having to manually open a broswer and type in the address.

Can anyone help with this?


It looks like you can do it without using iptables by using a hostapd configuration option

# Network Authentication Type
# This parameter indicates what type of network authentication is used in the
# network.
# format: <network auth type indicator (1-octet hex str)> [redirect URL]
# Network Authentication Type Indicator values:
# 00 = Acceptance of terms and conditions
# 01 = On-line enrollment supported  
# 02 = http/https redirection
# 03 = DNS redirection

I'd set it up as


and see what happens. I can't test it right now as none of my Raspberries are running as an access point.


  • looks great. ive tried adding this to my hostapd.conf file? I am going through the reference and Im unclear if i need more. my hostapd now looks like : interface=wlan0 driver=nl80211 ssid=RPiHotSpot hw_mode=g channel=6 wmm_enabled=0 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=1234567890 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP network_auth_type=02http:// – Colin Rosati Feb 6 at 15:42
  • Don't put my example URL in there. Your IP address is probably not And I'm 100% sure Node isn't running on port 1234. – Dougie Feb 6 at 20:08
  • I have changed my url to my server. Im just using your code in the example. I am using port 8001 (set from my node server) and set to my RPI IP address. I can confirm this address + port when a client and RPI are on the same wifi network. The issue seems to be this interworking disables my RPI wlan0 IP address in my setup. – Colin Rosati Feb 6 at 20:17

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.