0

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?

1

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
#network_auth_type=00
#network_auth_type=02http://www.example.com/redirect/me/here/

I'd set it up as

network_auth_type=02http://192.168.3.14:1234/url/for/node/js/stuff

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

https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf

  • 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://192.168.3.14:1234/ – colin rosati Feb 6 at 15:42
  • Don't put my example URL in there. Your IP address is probably not 192.168.3.14. 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.