Rack is a Ruby web server interface specification for building web applications. It defines an API for web servers to communicate with Ruby applications. Rack applications respond to the call method and return a three-element array containing the status, headers, and response. Rails uses Rack as its interface to communicate with web servers like WEBrick or Unicorn. Rack middleware can be added to Rails applications to add functionality like access logging or authentication. Common uses of Rack middleware include visitor counting, blocking access, and authentication with Devise.