Client server WiFi structure
Good directional antennas at both ends can extend WiFi to 2 km, but it won't be legal.  Maybe it's not a issue if you're in the middle of nowhere or your beam is well focused such that it doesn't spill past your own installation.  But that only means you are unlikely to get caught, not that it's legal.

Directional antennas are said to have "gain", but what that really means is gain in some direction as apposed to either a isotropic radiator or a dipole.  With a properly designed antenna, the WiFi circuitry can't tell the difference and it will send out the same power RF signal.  The high gain antenna will concentrate this power in a narrow beam, thereby increasing the radiation levels along that beam compared to a normal antenna.  However, the legal limit is specified as a particular maximum field stength (Volts/meter) at some specified distance from the transmitter.  This limit must be met in all directions, hence making conentrated beams with the same transmitted power as a dipole illegal.

In practise, the FCC (in the US) doesn't go looking for such violators.  It would take a complaint by a neighbor or someone to get them to look into it.  If you can focus the beam such that it stays on your property or ends at your installation by hitting the ground, going up, or getting blocked, then in practise you'll be OK.  Just don't go around advertising the fact that you're doing this.