Man page for dpkg.
Nginx was install originally via the nginx_1.14.1-1~bionic_amd64.deb package
$ dpkg -S /usr/sbin/nginx
nginx: /usr/sbin/nginx
Note: If the file is not in the package manager cache, installed without a *.deb package, it will not be listed.